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

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

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