提交 2f54b000 编写于 作者: J Joao Moreno

Merge branch 'feature-git-open-old-file' of https://github.com/Duroktar/vscode...

Merge branch 'feature-git-open-old-file' of https://github.com/Duroktar/vscode into Duroktar-feature-git-open-old-file
......@@ -59,6 +59,11 @@
"dark": "resources/icons/dark/open-file.svg"
}
},
{
"command": "git.openOldFile",
"title": "%command.openOldFile%",
"category": "Git"
},
{
"command": "git.stage",
"title": "%command.stage%",
......@@ -246,6 +251,10 @@
"command": "git.openFile",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.openOldFile",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.openChange",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
......@@ -513,6 +522,11 @@
"when": "config.git.enabled && scmProvider == git && gitState == idle && scmResourceGroup == index",
"group": "navigation"
},
{
"command": "git.openOldFile",
"when": "config.git.enabled && scmProvider == git && gitState == idle && scmResourceGroup == index",
"group": "navigation"
},
{
"command": "git.unstage",
"when": "config.git.enabled && scmProvider == git && gitState == idle && scmResourceGroup == index",
......@@ -528,6 +542,11 @@
"when": "config.git.enabled && scmProvider == git && gitState == idle && scmResourceGroup == workingTree",
"group": "navigation"
},
{
"command": "git.openOldFile",
"when": "config.git.enabled && scmProvider == git && gitState == idle && scmResourceGroup == workingTree",
"group": "navigation"
},
{
"command": "git.openFile",
"when": "config.git.enabled && scmProvider == git && gitState == idle && scmResourceGroup == workingTree",
......
......@@ -4,6 +4,7 @@
"command.refresh": "Refresh",
"command.openChange": "Open Changes",
"command.openFile": "Open File",
"command.openOldFile": "Open Old File",
"command.stage": "Stage Changes",
"command.stageAll": "Stage All Changes",
"command.stageSelectedRanges": "Stage Selected Ranges",
......
......@@ -313,6 +313,35 @@ export class CommandCenter {
return await commands.executeCommand<void>('vscode.open', uri, viewColumn);
}
@command('git.openOldFile')
async openOldFile(arg?: Resource | Uri): Promise<void> {
let resource: Resource | undefined = undefined;
if (arg instanceof Resource) {
resource = arg;
} else if (arg instanceof Uri) {
resource = this.getSCMResource(arg);
} else {
resource = this.getSCMResource();
}
if (!resource) {
return;
}
return await this._openOldResource(resource);
}
private async _openOldResource(resource: Resource): Promise<void> {
const old = this.getLeftResource(resource);
const current = this.getRightResource(resource);
if (!old) {
return await commands.executeCommand<void>('vscode.open', current);
}
return await commands.executeCommand<void>('vscode.open', old);
}
@command('git.openChange')
async openChange(arg?: Resource | Uri): Promise<void> {
let resource: Resource | undefined = undefined;
......@@ -328,7 +357,6 @@ export class CommandCenter {
if (!resource) {
return;
}
return await this._openResource(resource);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册