mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 06:17:18 +00:00
editors - do not eat error action results
This commit is contained in:
parent
d1ef72c22c
commit
4875bf81b7
|
@ -158,7 +158,7 @@ export class EditorPanes extends Disposable {
|
|||
}
|
||||
|
||||
const buttons: string[] = [];
|
||||
if (Array.isArray(errorActions) && errorActions.length > 0) {
|
||||
if (errorActions && errorActions.length > 0) {
|
||||
for (const errorAction of errorActions) {
|
||||
buttons.push(errorAction.label);
|
||||
}
|
||||
|
@ -183,10 +183,14 @@ export class EditorPanes extends Disposable {
|
|||
);
|
||||
|
||||
// Make sure to run any error action if present
|
||||
if (result.choice !== cancelId && Array.isArray(errorActions)) {
|
||||
if (result.choice !== cancelId && errorActions) {
|
||||
const errorAction = errorActions[result.choice];
|
||||
if (errorAction) {
|
||||
errorAction.run();
|
||||
const result = errorAction.run();
|
||||
if (result instanceof Promise) {
|
||||
result.catch(error => this.dialogService.show(Severity.Error, toErrorMessage(error)));
|
||||
}
|
||||
|
||||
errorHandled = true; // consider the error as handled!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import 'vs/css!./media/editorplaceholder';
|
||||
import { localize } from 'vs/nls';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IEditorOpenContext } from 'vs/workbench/common/editor';
|
||||
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
||||
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
||||
|
@ -28,6 +29,7 @@ import { editorErrorForeground, editorInfoForeground, editorWarningForeground }
|
|||
import { Codicon } from 'vs/base/common/codicons';
|
||||
import { FileChangeType, FileOperationError, FileOperationResult, IFileService } from 'vs/platform/files/common/files';
|
||||
import { isErrorWithActions, toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
|
||||
export interface IEditorPlaceholderContents {
|
||||
icon: string;
|
||||
|
@ -214,7 +216,8 @@ export class ErrorPlaceholderEditor extends EditorPlaceholder {
|
|||
@IThemeService themeService: IThemeService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IFileService private readonly fileService: IFileService
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IDialogService private readonly dialogService: IDialogService
|
||||
) {
|
||||
super(ErrorPlaceholderEditor.ID, telemetryService, themeService, storageService, instantiationService);
|
||||
}
|
||||
|
@ -241,7 +244,12 @@ export class ErrorPlaceholderEditor extends EditorPlaceholder {
|
|||
actions = error.actions.map(action => {
|
||||
return {
|
||||
label: action.label,
|
||||
run: () => action.run()
|
||||
run: () => {
|
||||
const result = action.run();
|
||||
if (result instanceof Promise) {
|
||||
result.catch(error => this.dialogService.show(Severity.Error, toErrorMessage(error)));
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
} else if (group) {
|
||||
|
|
Loading…
Reference in a new issue