diff --git a/extensions/git/package.json b/extensions/git/package.json index 78d56e7d74c..3d470fc2a26 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -815,7 +815,12 @@ }, { "command": "git.openFile2", - "when": "scmProvider == git && scmResourceGroup == merge && config.git.showInlineOpenFileAction", + "when": "scmProvider == git && scmResourceGroup == merge && config.git.showInlineOpenFileAction && config.git.openDiffOnClick", + "group": "inline0" + }, + { + "command": "git.openChange", + "when": "scmProvider == git && scmResourceGroup == merge && config.git.showInlineOpenFileAction && !config.git.openDiffOnClick", "group": "inline0" }, { @@ -845,7 +850,12 @@ }, { "command": "git.openFile2", - "when": "scmProvider == git && scmResourceGroup == index && config.git.showInlineOpenFileAction", + "when": "scmProvider == git && scmResourceGroup == index && config.git.showInlineOpenFileAction && config.git.openDiffOnClick", + "group": "inline0" + }, + { + "command": "git.openChange", + "when": "scmProvider == git && scmResourceGroup == index && config.git.showInlineOpenFileAction && !config.git.openDiffOnClick", "group": "inline0" }, { @@ -885,7 +895,12 @@ }, { "command": "git.openFile2", - "when": "scmProvider == git && scmResourceGroup == workingTree && config.git.showInlineOpenFileAction", + "when": "scmProvider == git && scmResourceGroup == workingTree && config.git.showInlineOpenFileAction && config.git.openDiffOnClick", + "group": "inline0" + }, + { + "command": "git.openChange", + "when": "scmProvider == git && scmResourceGroup == workingTree && config.git.showInlineOpenFileAction && !config.git.openDiffOnClick", "group": "inline0" }, { @@ -1204,6 +1219,11 @@ "type": "boolean", "default": true, "description": "%config.confirmForcePush%" + }, + "git.openDiffOnClick": { + "type": "boolean", + "default": true, + "description": "%config.openDiffOnClick%" } } }, diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index 5a0ec6339fc..837642fc22f 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -109,6 +109,7 @@ "config.allowForcePush": "Controls whether force push (with or without lease) is enabled.", "config.useForcePushWithLease": "Controls whether force pushing uses the safer force-with-lease variant.", "config.confirmForcePush": "Controls whether to ask for confirmation before force-pushing.", + "config.openDiffOnClick": "Controls whether the diff editor should be opened when clicking a change. Otherwise the regular editor will be opened.", "colors.added": "Color for added resources.", "colors.modified": "Color for modified resources.", "colors.deleted": "Color for deleted resources.", diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 312ed0d113d..88fef5ad941 100755 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -194,7 +194,20 @@ export class CommandCenter { @command('git.openResource') async openResource(resource: Resource): Promise { - await this._openResource(resource, undefined, true, false); + const repository = this.model.getRepository(resource.resourceUri); + + if (!repository) { + return; + } + + const config = workspace.getConfiguration('git', Uri.file(repository.root)); + const openDiffOnClick = config.get('openDiffOnClick'); + + if (openDiffOnClick) { + await this._openResource(resource, undefined, true, false); + } else { + await this.openFile(resource); + } } private async _openResource(resource: Resource, preview?: boolean, preserveFocus?: boolean, preserveSelection?: boolean): Promise {