From bd24f72d42d6ced671ee27803ec3bdbe5be7162e Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 29 Jun 2022 14:08:09 +0200 Subject: [PATCH] fix 153492 (#153667) * enable "accept merge" for merge editor only * close merge editor before staging file, only stage file when editor has been closed fixes https://github.com/microsoft/vscode/issues/153492 --- extensions/git/package.json | 3 ++- extensions/git/src/commands.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/extensions/git/package.json b/extensions/git/package.json index 0bec01c30a5..32c70fed3b7 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -586,7 +586,8 @@ { "command": "git.acceptMerge", "title": "%command.git.acceptMerge%", - "category": "Git" + "category": "Git", + "enablement": "isMergeEditor" } ], "keybindings": [ diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index e519e1de1c9..564206bfa58 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -1106,13 +1106,19 @@ export class CommandCenter { } 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; + let didCloseTab = false; if (activeTab && activeTab?.input instanceof TabInputText && activeTab.input.uri.toString() === uri.toString()) { - await window.tabGroups.close(activeTab, true); + didCloseTab = await window.tabGroups.close(activeTab, true); + } + + // Only stage if the merge editor has been successfully closed. That means all conflicts have been + // handled or unhandled conflicts are OK by the user. + if (didCloseTab) { + await repository.add([uri]); } }