diff --git a/src/vs/workbench/browser/parts/editor/editorGroupView.ts b/src/vs/workbench/browser/parts/editor/editorGroupView.ts index d2df00e4d5e39..29bfb9d670656 100644 --- a/src/vs/workbench/browser/parts/editor/editorGroupView.ts +++ b/src/vs/workbench/browser/parts/editor/editorGroupView.ts @@ -1555,7 +1555,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { // Let editor handle confirmation if implemented if (typeof editor.closeHandler?.confirm === 'function') { - confirmation = await editor.closeHandler.confirm(); + confirmation = await editor.closeHandler.confirm([{ editor, groupId: this.id }]); } // Show a file specific confirmation diff --git a/src/vs/workbench/common/editor/editorInput.ts b/src/vs/workbench/common/editor/editorInput.ts index 86b53423c6062..33fb8d838249f 100644 --- a/src/vs/workbench/common/editor/editorInput.ts +++ b/src/vs/workbench/common/editor/editorInput.ts @@ -30,10 +30,10 @@ export interface IEditorCloseHandler { * should be used besides dirty state, this method should be * implemented to show a different dialog. * - * @param editors if more than one editor is closed, will pass in - * each editor of the same kind to be able to show a combined dialog. + * @param editors All editors of the same kind that are being closed. Should be used + * to show a combined dialog. */ - confirm(editors?: ReadonlyArray): Promise; + confirm(editors: ReadonlyArray): Promise; } /** diff --git a/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts b/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts index 4f29941dc13b6..864214ae21028 100644 --- a/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts +++ b/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts @@ -173,21 +173,25 @@ class MergeEditorCloseHandler implements IEditorCloseHandler { return !this._ignoreUnhandledConflicts && this._model.hasUnhandledConflicts.get(); } - async confirm(editors?: readonly IEditorIdentifier[] | undefined): Promise { + async confirm(editors: readonly IEditorIdentifier[]): Promise { - const handler: MergeEditorCloseHandler[] = [this]; - editors?.forEach(candidate => candidate.editor.closeHandler instanceof MergeEditorCloseHandler && handler.push(candidate.editor.closeHandler)); + const handler: MergeEditorCloseHandler[] = []; + let someAreDirty = false; - const inputsWithUnhandledConflicts = handler - .filter(input => input._model && input._model.hasUnhandledConflicts.get()); + for (const { editor } of editors) { + if (editor.closeHandler instanceof MergeEditorCloseHandler && editor.closeHandler._model.hasUnhandledConflicts.get()) { + handler.push(editor.closeHandler); + someAreDirty = someAreDirty || editor.isDirty(); + } + } - if (inputsWithUnhandledConflicts.length === 0) { + if (handler.length === 0) { // shouldn't happen return ConfirmResult.SAVE; } const actions: string[] = [ - localize('unhandledConflicts.ignore', "Continue with Conflicts"), + someAreDirty ? localize('unhandledConflicts.saveAndIgnore', "Save & Continue with Conflicts") : localize('unhandledConflicts.ignore', "Continue with Conflicts"), localize('unhandledConflicts.discard', "Discard Merge Changes"), localize('unhandledConflicts.cancel', "Cancel"), ]; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts index 55032336cd5a5..dd5684d1ad817 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts @@ -100,7 +100,7 @@ export class TerminalEditorInput extends EditorInput implements IEditorCloseHand return false; } - async confirm(terminals?: ReadonlyArray): Promise { + async confirm(terminals: ReadonlyArray): Promise { const { choice } = await this._dialogService.show( Severity.Warning, localize('confirmDirtyTerminal.message', "Do you want to terminate running processes?"), @@ -110,7 +110,7 @@ export class TerminalEditorInput extends EditorInput implements IEditorCloseHand ], { cancelId: 1, - detail: terminals && terminals.length > 1 ? + detail: terminals.length > 1 ? terminals.map(terminal => terminal.editor.getName()).join('\n') + '\n\n' + localize('confirmDirtyTerminals.detail', "Closing will terminate the running processes in the terminals.") : localize('confirmDirtyTerminal.detail', "Closing will terminate the running processes in this terminal.") }