@@ -35,6 +35,7 @@ import { codespacesPrLink, getIssuesUrl, getPullsUrl, isInCodespaces, ISSUE_OR_U
3535import { OverviewContext } from './github/views' ;
3636import { isNotificationTreeItem , NotificationTreeItem } from './notifications/notificationItem' ;
3737import { NotificationsManager } from './notifications/notificationsManager' ;
38+ import { PullRequestsTreeDataProvider } from './view/prsTreeDataProvider' ;
3839import { PrsTreeModel } from './view/prsTreeModel' ;
3940import { ReviewCommentController } from './view/reviewCommentController' ;
4041import { ReviewManager } from './view/reviewManager' ;
@@ -135,7 +136,8 @@ export function registerCommands(
135136 telemetry : ITelemetry ,
136137 copilotRemoteAgentManager : CopilotRemoteAgentManager ,
137138 notificationManager : NotificationsManager ,
138- prsTreeModel : PrsTreeModel
139+ prsTreeModel : PrsTreeModel ,
140+ tree : PullRequestsTreeDataProvider
139141) {
140142 const logId = 'RegisterCommands' ;
141143 context . subscriptions . push (
@@ -233,10 +235,34 @@ export function registerCommands(
233235 ) ;
234236
235237 context . subscriptions . push (
236- vscode . commands . registerCommand ( 'pr.revealFileInOS' , ( e : GitFileChangeNode ) => {
237- const folderManager = reposManager . getManagerForIssueModel ( e . pullRequest ) ;
238+ vscode . commands . registerCommand ( 'pr.revealFileInOS' , ( e : GitFileChangeNode | InMemFileChangeNode | undefined ) => {
239+ let fileChangeNode : FileChangeNode | undefined = e ;
240+ // When invoked from a keybinding, get the selected item from the tree view
241+ if ( ! fileChangeNode ) {
242+ // First check the prStatus:github tree (checked out PRs)
243+ for ( const reviewManager of reviewsManager . reviewManagers ) {
244+ const selection = reviewManager . changesInPrDataProvider . view . selection ;
245+ const selectedFileChange = selection . find ( ( node ) : node is GitFileChangeNode => node instanceof GitFileChangeNode ) ;
246+ if ( selectedFileChange ) {
247+ fileChangeNode = selectedFileChange ;
248+ break ;
249+ }
250+ }
251+ // Then check the pr:github tree (non-checked out PRs)
252+ if ( ! fileChangeNode ) {
253+ const prTreeSelection = tree . view . selection ;
254+ const selectedInMemFileChange = prTreeSelection . find ( ( node ) : node is InMemFileChangeNode => node instanceof InMemFileChangeNode ) ;
255+ if ( selectedInMemFileChange ) {
256+ fileChangeNode = selectedInMemFileChange ;
257+ }
258+ }
259+ }
260+ if ( ! fileChangeNode ) {
261+ return ;
262+ }
263+ const folderManager = reposManager . getManagerForIssueModel ( fileChangeNode . pullRequest ) ;
238264 if ( folderManager ) {
239- const filePath = vscode . Uri . joinPath ( folderManager . repository . rootUri , e . changeModel . fileName ) ;
265+ const filePath = vscode . Uri . joinPath ( folderManager . repository . rootUri , fileChangeNode . changeModel . fileName ) ;
240266 vscode . commands . executeCommand ( 'revealFileInOS' , filePath ) ;
241267 }
242268 } ) ,
0 commit comments