Skip to content

Commit 4e39b54

Browse files
Copilotalexr00
andcommitted
Add Reveal in File Explorer command for PR files
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 9d0a254 commit 4e39b54

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

package.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,11 @@
10331033
"title": "%command.pr.openFileOnGitHub.title%",
10341034
"category": "%command.pull.request.category%"
10351035
},
1036+
{
1037+
"command": "pr.revealFileInOS",
1038+
"title": "%command.pr.revealFileInOS.title%",
1039+
"category": "%command.pull.request.category%"
1040+
},
10361041
{
10371042
"command": "pr.copyCommitHash",
10381043
"title": "%command.pr.copyCommitHash.title%",
@@ -2118,6 +2123,10 @@
21182123
"command": "pr.openFileOnGitHub",
21192124
"when": "false"
21202125
},
2126+
{
2127+
"command": "pr.revealFileInOS",
2128+
"when": "false"
2129+
},
21212130
{
21222131
"command": "pr.openOriginalFile",
21232132
"when": "false"
@@ -2963,15 +2972,20 @@
29632972
"when": "view =~ /(pr|prStatus):github/ && viewItem =~ /filechange/",
29642973
"group": "0_open@0"
29652974
},
2975+
{
2976+
"command": "pr.revealFileInOS",
2977+
"when": "view =~ /(pr|prStatus):github/ && viewItem =~ /filechange.*:local/ && viewItem !~ /filechange:DELETE/",
2978+
"group": "0_open@1"
2979+
},
29662980
{
29672981
"command": "pr.openOriginalFile",
29682982
"when": "view =~ /(pr|prStatus):github/ && viewItem =~ /filechange:MODIFY/",
2969-
"group": "0_open@1"
2983+
"group": "0_open@2"
29702984
},
29712985
{
29722986
"command": "pr.openModifiedFile",
29732987
"when": "view =~ /(pr|prStatus):github/ && viewItem =~ /filechange:MODIFY/",
2974-
"group": "0_open@2"
2988+
"group": "0_open@3"
29752989
},
29762990
{
29772991
"command": "review.diffWithPrHead",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
"command.pr.openAllDiffs.title": "Open All Diffs",
200200
"command.pr.refreshPullRequest.title": "Refresh Pull Request",
201201
"command.pr.openFileOnGitHub.title": "Open File on GitHub",
202+
"command.pr.revealFileInOS.title": "Reveal in File Explorer",
202203
"command.pr.copyCommitHash.title": "Copy Commit Hash",
203204
"command.pr.openOriginalFile.title": "Open Original File",
204205
"command.pr.openModifiedFile.title": "Open Modified File",

src/commands.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ export function registerCommands(
232232
}),
233233
);
234234

235+
context.subscriptions.push(
236+
vscode.commands.registerCommand('pr.revealFileInOS', (e: GitFileChangeNode) => {
237+
const folderManager = reposManager.getManagerForIssueModel(e.pullRequest);
238+
if (folderManager) {
239+
const filePath = vscode.Uri.joinPath(folderManager.repository.rootUri, e.changeModel.fileName);
240+
vscode.commands.executeCommand('revealFileInOS', filePath);
241+
}
242+
}),
243+
);
244+
235245
context.subscriptions.push(
236246
vscode.commands.registerCommand('pr.openOriginalFile', async (e: GitFileChangeNode) => {
237247
// if this is an image, encode it as a base64 data URI

src/view/treeNodes/fileChangeNode.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ export class GitFileChangeNode extends FileChangeNode implements vscode.TreeItem
299299
private _comments?: IComment[]
300300
) {
301301
super(parent, pullRequestManager, pullRequest, changeModel);
302+
// Mark as local file to distinguish from remote files
303+
this.contextValue = `${this.contextValue}:local`;
304+
}
305+
306+
override updateViewed(viewed: ViewedState) {
307+
super.updateViewed(viewed);
308+
// Re-append the :local suffix after parent updates contextValue
309+
this.contextValue = `${this.contextValue}:local`;
302310
}
303311

304312
get comments(): IComment[] {

0 commit comments

Comments
 (0)