Skip to content

Commit

Permalink
introduce git.openDiffOnClick
Browse files Browse the repository at this point in the history
fixes #63005
  • Loading branch information
joaomoreno committed Nov 19, 2018
1 parent eb6025e commit e5406b5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
26 changes: 23 additions & 3 deletions extensions/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
{
Expand Down Expand Up @@ -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"
},
{
Expand Down Expand Up @@ -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"
},
{
Expand Down Expand Up @@ -1204,6 +1219,11 @@
"type": "boolean",
"default": true,
"description": "%config.confirmForcePush%"
},
"git.openDiffOnClick": {
"type": "boolean",
"default": true,
"description": "%config.openDiffOnClick%"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions extensions/git/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
15 changes: 14 additions & 1 deletion extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,20 @@ export class CommandCenter {

@command('git.openResource')
async openResource(resource: Resource): Promise<void> {
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<boolean>('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<void> {
Expand Down

0 comments on commit e5406b5

Please sign in to comment.