Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes <johannes.rieken@gmail.com>2022-05-25 18:43:02 +0300
committerJohannes <johannes.rieken@gmail.com>2022-05-25 18:43:02 +0300
commitce01702bbec4419cfb76ab10d2b04ce09d3f6600 (patch)
treed888df544546fb95aa060afd961c831fb4c0a902 /extensions
parent38931b6a3db467bf1c5ba51f053ddedbeeed6acd (diff)
make git "accept from merge editor" command save the document and close the merge editor (uses heuristic to identify merge editor tab)
Diffstat (limited to 'extensions')
-rw-r--r--extensions/git/src/commands.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts
index da619d4feb5..2805dcab768 100644
--- a/extensions/git/src/commands.ts
+++ b/extensions/git/src/commands.ts
@@ -6,7 +6,7 @@
import * as os from 'os';
import * as path from 'path';
import * as picomatch from 'picomatch';
-import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity } from 'vscode';
+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';
import TelemetryReporter from '@vscode/extension-telemetry';
import * as nls from 'vscode-nls';
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
@@ -1082,15 +1082,30 @@ export class CommandCenter {
@command('git.acceptMerge')
async acceptMerge(uri: Uri | unknown): Promise<void> {
- // TODO@jrieken make this proper, needs help from SCM folks
if (!(uri instanceof Uri)) {
return;
}
const repository = this.model.getRepository(uri);
if (!repository) {
+ console.log(`FAILED to accept merge because uri ${uri.toString()} doesn't belong to any repository`);
return;
}
+
+ const doc = workspace.textDocuments.find(doc => doc.uri.toString() === uri.toString());
+ if (!doc) {
+ console.log(`FAILED to accept merge because uri ${uri.toString()} doesn't match a document`);
+ return;
+ }
+
+ await doc.save();
await repository.add([uri]);
+
+ // TODO@jrieken there isn't a `TabInputTextMerge` instance yet, till now the merge editor
+ // uses the `TabInputText` for the out-resource and we use that to identify and CLOSE the tab
+ const { activeTab } = window.tabGroups.activeTabGroup;
+ if (activeTab && activeTab?.input instanceof TabInputText && activeTab.input.uri.toString() === uri.toString()) {
+ await window.tabGroups.close(activeTab, true);
+ }
}
private async _stageChanges(textEditor: TextEditor, changes: LineChange[]): Promise<void> {