This commit is contained in:
Joao Moreno 2017-06-26 16:14:29 +02:00
parent 2f54b0001b
commit 91a02c7a0a
3 changed files with 14 additions and 17 deletions

View file

@ -60,8 +60,8 @@
}
},
{
"command": "git.openOldFile",
"title": "%command.openOldFile%",
"command": "git.openHEADFile",
"title": "%command.openHEADFile%",
"category": "Git"
},
{
@ -252,7 +252,7 @@
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.openOldFile",
"command": "git.openHEADFile",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
@ -523,7 +523,7 @@
"group": "navigation"
},
{
"command": "git.openOldFile",
"command": "git.openHEADFile",
"when": "config.git.enabled && scmProvider == git && gitState == idle && scmResourceGroup == index",
"group": "navigation"
},
@ -543,7 +543,7 @@
"group": "navigation"
},
{
"command": "git.openOldFile",
"command": "git.openHEADFile",
"when": "config.git.enabled && scmProvider == git && gitState == idle && scmResourceGroup == workingTree",
"group": "navigation"
},

View file

@ -4,7 +4,7 @@
"command.refresh": "Refresh",
"command.openChange": "Open Changes",
"command.openFile": "Open File",
"command.openOldFile": "Open Old File",
"command.openHEADFile": "Open File (HEAD)",
"command.stage": "Stage Changes",
"command.stageAll": "Stage All Changes",
"command.stageSelectedRanges": "Stage Selected Ranges",

View file

@ -313,13 +313,12 @@ export class CommandCenter {
return await commands.executeCommand<void>('vscode.open', uri, viewColumn);
}
@command('git.openOldFile')
async openOldFile(arg?: Resource | Uri): Promise<void> {
@command('git.openHEADFile')
async openHEADFile(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 {
@ -329,17 +328,15 @@ export class CommandCenter {
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);
const HEAD = this.getLeftResource(resource);
if (!old) {
return await commands.executeCommand<void>('vscode.open', current);
if (!HEAD) {
window.showWarningMessage(localize('HEAD not available', "HEAD version of '{0}' is not available.", path.basename(resource.resourceUri.fsPath)));
return;
}
return await commands.executeCommand<void>('vscode.open', old);
return await commands.executeCommand<void>('vscode.open', HEAD);
}
@command('git.openChange')