Skip to content

Commit 0f0101b

Browse files
committed
use TabInputTextMerge in git extensions
For now only when checking for tabs, not yet for opening tabs
1 parent 40df705 commit 0f0101b

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

extensions/git/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"scmActionButton",
1717
"scmSelectedProvider",
1818
"scmValidation",
19+
"tabInputTextMerge",
1920
"timeline"
2021
],
2122
"categories": [

extensions/git/src/commands.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as os from 'os';
77
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';
99
import TelemetryReporter from '@vscode/extension-telemetry';
1010
import * as nls from 'vscode-nls';
1111
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
@@ -1099,21 +1099,26 @@ export class CommandCenter {
10991099
return;
11001100
}
11011101

1102+
const { activeTab } = window.tabGroups.activeTabGroup;
1103+
if (!activeTab) {
1104+
return;
1105+
}
1106+
1107+
// make sure to save the merged document
11021108
const doc = workspace.textDocuments.find(doc => doc.uri.toString() === uri.toString());
11031109
if (!doc) {
11041110
console.log(`FAILED to accept merge because uri ${uri.toString()} doesn't match a document`);
11051111
return;
11061112
}
1113+
if (doc.isDirty) {
1114+
await doc.save();
1115+
}
11071116

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
11141118
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);
11171122
}
11181123

11191124
// Only stage if the merge editor has been successfully closed. That means all conflicts have been

extensions/git/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"../../src/vscode-dts/vscode.proposed.scmActionButton.d.ts",
1515
"../../src/vscode-dts/vscode.proposed.scmSelectedProvider.d.ts",
1616
"../../src/vscode-dts/vscode.proposed.scmValidation.d.ts",
17-
"../../src/vscode-dts/vscode.proposed.tabs.d.ts",
17+
"../../src/vscode-dts/vscode.proposed.tabInputTextMerge.d.ts",
1818
"../../src/vscode-dts/vscode.proposed.timeline.d.ts",
1919
"../types/lib.textEncoder.d.ts"
2020
]

0 commit comments

Comments
 (0)