Skip to content

Commit 90a6462

Browse files
committed
tweak message when closing dirty and conflicting merge editor
fyi @bpasero this ensures the close handler is always called with `IEditorIdentifier[]` re #152841
1 parent e06f679 commit 90a6462

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

src/vs/workbench/browser/parts/editor/editorGroupView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
15551555

15561556
// Let editor handle confirmation if implemented
15571557
if (typeof editor.closeHandler?.confirm === 'function') {
1558-
confirmation = await editor.closeHandler.confirm();
1558+
confirmation = await editor.closeHandler.confirm([{ editor, groupId: this.id }]);
15591559
}
15601560

15611561
// Show a file specific confirmation

src/vs/workbench/common/editor/editorInput.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export interface IEditorCloseHandler {
3030
* should be used besides dirty state, this method should be
3131
* implemented to show a different dialog.
3232
*
33-
* @param editors if more than one editor is closed, will pass in
34-
* each editor of the same kind to be able to show a combined dialog.
33+
* @param editors All editors of the same kind that are being closed. Should be used
34+
* to show a combined dialog.
3535
*/
36-
confirm(editors?: ReadonlyArray<IEditorIdentifier>): Promise<ConfirmResult>;
36+
confirm(editors: ReadonlyArray<IEditorIdentifier>): Promise<ConfirmResult>;
3737
}
3838

3939
/**

src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,25 @@ class MergeEditorCloseHandler implements IEditorCloseHandler {
173173
return !this._ignoreUnhandledConflicts && this._model.hasUnhandledConflicts.get();
174174
}
175175

176-
async confirm(editors?: readonly IEditorIdentifier[] | undefined): Promise<ConfirmResult> {
176+
async confirm(editors: readonly IEditorIdentifier[]): Promise<ConfirmResult> {
177177

178-
const handler: MergeEditorCloseHandler[] = [this];
179-
editors?.forEach(candidate => candidate.editor.closeHandler instanceof MergeEditorCloseHandler && handler.push(candidate.editor.closeHandler));
178+
const handler: MergeEditorCloseHandler[] = [];
179+
let someAreDirty = false;
180180

181-
const inputsWithUnhandledConflicts = handler
182-
.filter(input => input._model && input._model.hasUnhandledConflicts.get());
181+
for (const { editor } of editors) {
182+
if (editor.closeHandler instanceof MergeEditorCloseHandler && editor.closeHandler._model.hasUnhandledConflicts.get()) {
183+
handler.push(editor.closeHandler);
184+
someAreDirty = someAreDirty || editor.isDirty();
185+
}
186+
}
183187

184-
if (inputsWithUnhandledConflicts.length === 0) {
188+
if (handler.length === 0) {
185189
// shouldn't happen
186190
return ConfirmResult.SAVE;
187191
}
188192

189193
const actions: string[] = [
190-
localize('unhandledConflicts.ignore', "Continue with Conflicts"),
194+
someAreDirty ? localize('unhandledConflicts.saveAndIgnore', "Save & Continue with Conflicts") : localize('unhandledConflicts.ignore', "Continue with Conflicts"),
191195
localize('unhandledConflicts.discard', "Discard Merge Changes"),
192196
localize('unhandledConflicts.cancel', "Cancel"),
193197
];

src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class TerminalEditorInput extends EditorInput implements IEditorCloseHand
100100
return false;
101101
}
102102

103-
async confirm(terminals?: ReadonlyArray<IEditorIdentifier>): Promise<ConfirmResult> {
103+
async confirm(terminals: ReadonlyArray<IEditorIdentifier>): Promise<ConfirmResult> {
104104
const { choice } = await this._dialogService.show(
105105
Severity.Warning,
106106
localize('confirmDirtyTerminal.message', "Do you want to terminate running processes?"),
@@ -110,7 +110,7 @@ export class TerminalEditorInput extends EditorInput implements IEditorCloseHand
110110
],
111111
{
112112
cancelId: 1,
113-
detail: terminals && terminals.length > 1 ?
113+
detail: terminals.length > 1 ?
114114
terminals.map(terminal => terminal.editor.getName()).join('\n') + '\n\n' + localize('confirmDirtyTerminals.detail', "Closing will terminate the running processes in the terminals.") :
115115
localize('confirmDirtyTerminal.detail', "Closing will terminate the running processes in this terminal.")
116116
}

0 commit comments

Comments
 (0)