diff --git a/package.json b/package.json index 7d8512f82..355964d9b 100644 --- a/package.json +++ b/package.json @@ -305,6 +305,16 @@ "title": "Copy Commit Hash", "category": "GitHub Pull Requests" }, + { + "command": "pr.openOriginalFile", + "title": "Open Original File", + "category": "GitHub Pull Requests" + }, + { + "command": "pr.openModifiedFile", + "title": "Open Modified File", + "category": "GitHub Pull Requests" + }, { "command": "pr.openDiffView", "title": "Open Diff View", @@ -517,6 +527,14 @@ "command": "pr.openFileInGitHub", "when": "false" }, + { + "command": "pr.openOriginalFile", + "when": "false" + }, + { + "command": "pr.openModifiedFile", + "when": "false" + }, { "command": "pr.refreshPullRequest", "when": "false" @@ -655,6 +673,14 @@ "command": "pr.openDiffView", "group": "inline", "when": "!config.git.openDiffOnClick && view =~ /prStatus/ && viewItem =~ /filechange(?!:DELETE)/" + }, + { + "command": "pr.openOriginalFile", + "when": "view =~ /(pr|prStatus)/ && viewItem =~ /filechange:MODIFY/" + }, + { + "command": "pr.openModifiedFile", + "when": "view =~ /(pr|prStatus)/ && viewItem =~ /filechange:MODIFY/" } ], "editor/title": [ diff --git a/src/commands.ts b/src/commands.ts index 9f248ff18..bc8b50bd8 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -140,6 +140,14 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: Pu vscode.env.clipboard.writeText(e.sha); })); + context.subscriptions.push(vscode.commands.registerCommand('pr.openOriginalFile', (e: GitFileChangeNode) => { + vscode.commands.executeCommand('vscode.open', e.parentFilePath); + })); + + context.subscriptions.push(vscode.commands.registerCommand('pr.openModifiedFile', (e: GitFileChangeNode) => { + vscode.commands.executeCommand('vscode.open', e.filePath); + })); + context.subscriptions.push(vscode.commands.registerCommand('pr.openDiffView', (fileChangeNode: GitFileChangeNode | InMemFileChangeNode) => { const parentFilePath = fileChangeNode.parentFilePath; const filePath = fileChangeNode.filePath; diff --git a/src/view/treeNodes/fileChangeNode.ts b/src/view/treeNodes/fileChangeNode.ts index 30b285bf4..0fbb653c3 100644 --- a/src/view/treeNodes/fileChangeNode.ts +++ b/src/view/treeNodes/fileChangeNode.ts @@ -79,7 +79,7 @@ export class InMemFileChangeNode extends TreeNode implements vscode.TreeItem { public readonly sha?: string ) { super(); - this.contextValue = 'filechange'; + this.contextValue = `filechange:${GitChangeType[status]}`; this.label = path.basename(fileName); this.description = path.relative('.', path.dirname(fileName)); this.iconPath = vscode.ThemeIcon.File;