diff options
author | Johannes <johannes.rieken@gmail.com> | 2022-05-25 18:08:15 +0300 |
---|---|---|
committer | Johannes <johannes.rieken@gmail.com> | 2022-05-25 18:08:15 +0300 |
commit | 38931b6a3db467bf1c5ba51f053ddedbeeed6acd (patch) | |
tree | 5416e59bcf674ccc416d81064420350991245354 /extensions | |
parent | 1ed660b17e3c01e57937bbfb53aadf21407ceb11 (diff) |
add `git.experimental.mergeEditor` setting to enable/disable merge editor for conflicting files
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/git/package.json | 6 | ||||
-rw-r--r-- | extensions/git/package.nls.json | 1 | ||||
-rw-r--r-- | extensions/git/src/repository.ts | 37 |
3 files changed, 32 insertions, 12 deletions
diff --git a/extensions/git/package.json b/extensions/git/package.json index bb077b6f23d..b5ad659a010 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -2445,6 +2445,12 @@ ], "markdownDescription": "%config.logLevel%", "scope": "window" + }, + "git.experimental.mergeEditor": { + "type": "boolean", + "default": false, + "markdownDescription": "%config.experimental.mergeEditor%", + "scope": "window" } } }, diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index e43df92114f..e1a8c6a9faf 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -236,6 +236,7 @@ "config.logLevel.error": "Log only error, and critical information", "config.logLevel.critical": "Log only critical information", "config.logLevel.off": "Log nothing", + "config.experimental.mergeEditor": "Open the _experimental_ merge editor for files that are currently under conflict.", "submenu.explorer": "Git", "submenu.commit": "Commit", "submenu.commit.amend": "Amend", diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index ebe1105ab94..61548892e7c 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -296,6 +296,10 @@ export class Resource implements SourceControlResourceState { const command = this._commandResolver.resolveChangeCommand(this); await commands.executeCommand<void>(command.command, ...(command.arguments || [])); } + + clone() { + return new Resource(this._commandResolver, this._resourceGroupType, this._resourceUri, this._type, this._useIcons, this._renameResourceUri); + } } export const enum Operation { @@ -602,18 +606,21 @@ class ResourceCommandResolver { resolveChangeCommand(resource: Resource): Command { const title = this.getTitle(resource); - if (!resource.leftUri && resource.rightUri && resource.type === Status.BOTH_MODIFIED) { - return { - command: '_git.openMergeEditor', - title: localize('open.merge', "Open Merge"), - arguments: [resource.rightUri] - }; - } else if (!resource.leftUri) { - return { - command: 'vscode.open', - title: localize('open', "Open"), - arguments: [resource.rightUri, { override: resource.type === Status.BOTH_MODIFIED ? false : undefined }, title] - }; + if (!resource.leftUri) { + const bothModified = resource.type === Status.BOTH_MODIFIED; + if (resource.rightUri && bothModified && workspace.getConfiguration('git').get<boolean>('experimental.mergeEditor', false)) { + return { + command: '_git.openMergeEditor', + title: localize('open.merge', "Open Merge"), + arguments: [resource.rightUri] + }; + } else { + return { + command: 'vscode.open', + title: localize('open', "Open"), + arguments: [resource.rightUri, { override: bothModified ? false : undefined }, title] + }; + } } else { return { command: 'vscode.diff', @@ -918,6 +925,12 @@ export class Repository implements Disposable { onConfigListener(updateIndexGroupVisibility, this, this.disposables); updateIndexGroupVisibility(); + workspace.onDidChangeConfiguration(e => { + if (e.affectsConfiguration('git.experimental.mergeEditor')) { + this.mergeGroup.resourceStates = this.mergeGroup.resourceStates.map(r => r.clone()); + } + }, undefined, this.disposables); + filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git.branchSortOrder', root) || e.affectsConfiguration('git.untrackedChanges', root) |