提交 8d01db6d 编写于 作者: J Joao Moreno

🐛 split git open file/changes into two sets of commands

fixes #23729
上级 8ef40c6b
...@@ -63,6 +63,24 @@ ...@@ -63,6 +63,24 @@
"dark": "resources/icons/dark/open-file.svg" "dark": "resources/icons/dark/open-file.svg"
} }
}, },
{
"command": "git.openChangeFromUri",
"title": "%command.openChange%",
"category": "Git",
"icon": {
"light": "resources/icons/light/open-change.svg",
"dark": "resources/icons/dark/open-change.svg"
}
},
{
"command": "git.openFileFromUri",
"title": "%command.openFile%",
"category": "Git",
"icon": {
"light": "resources/icons/light/open-file.svg",
"dark": "resources/icons/dark/open-file.svg"
}
},
{ {
"command": "git.stage", "command": "git.stage",
"title": "%command.stage%", "title": "%command.stage%",
...@@ -228,10 +246,18 @@ ...@@ -228,10 +246,18 @@
}, },
{ {
"command": "git.openChange", "command": "git.openChange",
"when": "config.git.enabled && scmProvider == git && gitState == idle" "when": "false"
}, },
{ {
"command": "git.openFile", "command": "git.openFile",
"when": "false"
},
{
"command": "git.openChangeFromUri",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.openFileFromUri",
"when": "config.git.enabled && scmProvider == git && gitState == idle" "when": "config.git.enabled && scmProvider == git && gitState == idle"
}, },
{ {
...@@ -524,12 +550,12 @@ ...@@ -524,12 +550,12 @@
], ],
"editor/title": [ "editor/title": [
{ {
"command": "git.openFile", "command": "git.openFileFromUri",
"group": "navigation", "group": "navigation",
"when": "config.git.enabled && scmProvider == git && isInDiffEditor && resourceScheme != extension" "when": "config.git.enabled && scmProvider == git && isInDiffEditor && resourceScheme != extension"
}, },
{ {
"command": "git.openChange", "command": "git.openChangeFromUri",
"group": "navigation", "group": "navigation",
"when": "config.git.enabled && scmProvider == git && !isInDiffEditor && resourceScheme != extension" "when": "config.git.enabled && scmProvider == git && !isInDiffEditor && resourceScheme != extension"
} }
......
...@@ -261,10 +261,32 @@ export class CommandCenter { ...@@ -261,10 +261,32 @@ export class CommandCenter {
return await this._openResource(resource); return await this._openResource(resource);
} }
@command('git.openFileFromUri')
async openFileFromUri(uri?: Uri): Promise<void> {
const resource = this.getSCMResource(uri);
if (!resource) {
return;
}
return await commands.executeCommand<void>('vscode.open', resource.resourceUri);
}
@command('git.openChangeFromUri')
async openChangeFromUri(uri?: Uri): Promise<void> {
const resource = this.getSCMResource(uri);
if (!resource) {
return;
}
return await this._openResource(resource);
}
@command('git.stage') @command('git.stage')
async stage(...resourceStates: SourceControlResourceState[]): Promise<void> { async stage(...resourceStates: SourceControlResourceState[]): Promise<void> {
if (resourceStates.length === 0) { if (resourceStates.length === 0) {
const resource = this.getActiveEditorSCMResource(); const resource = this.getSCMResource();
if (!resource) { if (!resource) {
return; return;
...@@ -370,7 +392,7 @@ export class CommandCenter { ...@@ -370,7 +392,7 @@ export class CommandCenter {
@command('git.unstage') @command('git.unstage')
async unstage(...resourceStates: SourceControlResourceState[]): Promise<void> { async unstage(...resourceStates: SourceControlResourceState[]): Promise<void> {
if (resourceStates.length === 0) { if (resourceStates.length === 0) {
const resource = this.getActiveEditorSCMResource(); const resource = this.getSCMResource();
if (!resource) { if (!resource) {
return; return;
...@@ -438,7 +460,7 @@ export class CommandCenter { ...@@ -438,7 +460,7 @@ export class CommandCenter {
@command('git.clean') @command('git.clean')
async clean(...resourceStates: SourceControlResourceState[]): Promise<void> { async clean(...resourceStates: SourceControlResourceState[]): Promise<void> {
if (resourceStates.length === 0) { if (resourceStates.length === 0) {
const resource = this.getActiveEditorSCMResource(); const resource = this.getSCMResource();
if (!resource) { if (!resource) {
return; return;
...@@ -791,8 +813,8 @@ export class CommandCenter { ...@@ -791,8 +813,8 @@ export class CommandCenter {
return result; return result;
} }
private getActiveEditorSCMResource(): Resource | undefined { private getSCMResource(uri?: Uri): Resource | undefined {
let uri = window.activeTextEditor && window.activeTextEditor.document.uri; uri = uri ? uri : window.activeTextEditor && window.activeTextEditor.document.uri;
if (!uri) { if (!uri) {
return undefined; return undefined;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册