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]); } }