|
5 | 5 |
|
6 | 6 | import * as os from 'os';
|
7 | 7 | import * as path from 'path';
|
8 |
| -import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText } from 'vscode'; |
| 8 | +import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge } from 'vscode'; |
9 | 9 | import TelemetryReporter from '@vscode/extension-telemetry';
|
10 | 10 | import * as nls from 'vscode-nls';
|
11 | 11 | import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
|
@@ -1099,21 +1099,26 @@ export class CommandCenter {
|
1099 | 1099 | return;
|
1100 | 1100 | }
|
1101 | 1101 |
|
| 1102 | + const { activeTab } = window.tabGroups.activeTabGroup; |
| 1103 | + if (!activeTab) { |
| 1104 | + return; |
| 1105 | + } |
| 1106 | + |
| 1107 | + // make sure to save the merged document |
1102 | 1108 | const doc = workspace.textDocuments.find(doc => doc.uri.toString() === uri.toString());
|
1103 | 1109 | if (!doc) {
|
1104 | 1110 | console.log(`FAILED to accept merge because uri ${uri.toString()} doesn't match a document`);
|
1105 | 1111 | return;
|
1106 | 1112 | }
|
| 1113 | + if (doc.isDirty) { |
| 1114 | + await doc.save(); |
| 1115 | + } |
1107 | 1116 |
|
1108 |
| - await doc.save(); |
1109 |
| - |
1110 |
| - // TODO@jrieken there isn't a `TabInputTextMerge` instance yet, till now the merge editor |
1111 |
| - // uses the `TabInputText` for the out-resource and we use that to identify and CLOSE the tab |
1112 |
| - // see https://github.com/microsoft/vscode/issues/153213 |
1113 |
| - const { activeTab } = window.tabGroups.activeTabGroup; |
| 1117 | + // find the merge editor tabs for the resource in question and close them all |
1114 | 1118 | let didCloseTab = false;
|
1115 |
| - if (activeTab && activeTab?.input instanceof TabInputText && activeTab.input.uri.toString() === uri.toString()) { |
1116 |
| - didCloseTab = await window.tabGroups.close(activeTab, true); |
| 1119 | + const mergeEditorTabs = window.tabGroups.all.map(group => group.tabs.filter(tab => tab.input instanceof TabInputTextMerge && tab.input.result.toString() === uri.toString())).flat(); |
| 1120 | + if (mergeEditorTabs.includes(activeTab)) { |
| 1121 | + didCloseTab = await window.tabGroups.close(mergeEditorTabs, true); |
1117 | 1122 | }
|
1118 | 1123 |
|
1119 | 1124 | // Only stage if the merge editor has been successfully closed. That means all conflicts have been
|
|
0 commit comments