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

View file

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

View file

@ -313,13 +313,12 @@ export class CommandCenter {
return await commands.executeCommand<void>('vscode.open', uri, viewColumn); return await commands.executeCommand<void>('vscode.open', uri, viewColumn);
} }
@command('git.openOldFile') @command('git.openHEADFile')
async openOldFile(arg?: Resource | Uri): Promise<void> { async openHEADFile(arg?: Resource | Uri): Promise<void> {
let resource: Resource | undefined = undefined; let resource: Resource | undefined = undefined;
if (arg instanceof Resource) { if (arg instanceof Resource) {
resource = arg; resource = arg;
} else if (arg instanceof Uri) { } else if (arg instanceof Uri) {
resource = this.getSCMResource(arg); resource = this.getSCMResource(arg);
} else { } else {
@ -329,17 +328,15 @@ export class CommandCenter {
if (!resource) { if (!resource) {
return; return;
} }
return await this._openOldResource(resource);
}
private async _openOldResource(resource: Resource): Promise<void> { const HEAD = this.getLeftResource(resource);
const old = this.getLeftResource(resource);
const current = this.getRightResource(resource);
if (!old) { if (!HEAD) {
return await commands.executeCommand<void>('vscode.open', current); 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') @command('git.openChange')