add git.experimental.mergeEditor setting to enable/disable merge editor for conflicting files

This commit is contained in:
Johannes 2022-05-25 17:08:15 +02:00
parent 1ed660b17e
commit 38931b6a3d
No known key found for this signature in database
GPG key ID: 6DEF802A22264FCA
3 changed files with 32 additions and 12 deletions

View file

@ -2445,6 +2445,12 @@
],
"markdownDescription": "%config.logLevel%",
"scope": "window"
},
"git.experimental.mergeEditor": {
"type": "boolean",
"default": false,
"markdownDescription": "%config.experimental.mergeEditor%",
"scope": "window"
}
}
},

View file

@ -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",

View file

@ -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)