提交 54da9357 编写于 作者: D Duroktar

add "open old file" git command

this implements #23011
上级 78676ce5
......@@ -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%",
......@@ -226,6 +231,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"
......@@ -477,6 +486,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",
......@@ -492,6 +506,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",
......
......@@ -275,6 +275,35 @@ export class CommandCenter {
return await commands.executeCommand<void>('vscode.open', uri);
}
@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;
......@@ -290,7 +319,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.
先完成此消息的编辑!
想要评论请 注册