@@ -20,9 +20,11 @@ import {
2020import type { HomeTelemetryContext , Source } from '../../constants.telemetry' ;
2121import type { Container } from '../../container' ;
2222import { executeGitCommand } from '../../git/actions' ;
23+ import { revealBranch } from '../../git/actions/branch' ;
2324import { openComparisonChanges } from '../../git/actions/commit' ;
2425import { abortPausedOperation , continuePausedOperation , skipPausedOperation } from '../../git/actions/pausedOperation' ;
2526import * as RepoActions from '../../git/actions/repository' ;
27+ import { revealWorktree } from '../../git/actions/worktree' ;
2628import type { BranchContributionsOverview } from '../../git/gitProvider' ;
2729import type { GitBranch } from '../../git/models/branch' ;
2830import type { GitFileChangeShape } from '../../git/models/fileChange' ;
@@ -363,6 +365,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
363365 registerCommand ( 'gitlens.home.openInGraph' , this . openInGraph , this ) ,
364366 registerCommand ( 'gitlens.visualizeHistory.repo:home' , this . openInTimeline , this ) ,
365367 registerCommand ( 'gitlens.visualizeHistory.branch:home' , this . openInTimeline , this ) ,
368+ registerCommand ( 'gitlens.openInView.branch:home' , this . openInView , this ) ,
366369 registerCommand ( 'gitlens.home.createBranch' , this . createBranch , this ) ,
367370 registerCommand ( 'gitlens.home.mergeIntoCurrent' , this . mergeIntoCurrent , this ) ,
368371 registerCommand ( 'gitlens.home.rebaseCurrentOnto' , this . rebaseCurrentOnto , this ) ,
@@ -527,6 +530,22 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
527530 }
528531 }
529532
533+ @log < HomeWebviewProvider [ 'openInView' ] > ( {
534+ args : { 0 : p => `repoPath=${ p ?. repoPath } , branchId=${ p ?. branchId } ` } ,
535+ } )
536+ private async openInView ( params : BranchRef ) {
537+ const { repo, branch } = await this . getRepoInfoFromRef ( params ) ;
538+ if ( repo == null || branch == null ) return ;
539+
540+ // Show in the Worktrees or Branches view depending
541+ const worktree = await branch . getWorktree ( ) ;
542+ if ( worktree != null && ! worktree . isDefault ) {
543+ await revealWorktree ( worktree , { select : true , focus : true , expand : true } ) ;
544+ } else {
545+ await revealBranch ( branch , { select : true , focus : true , expand : true } ) ;
546+ }
547+ }
548+
530549 @log ( )
531550 private createBranch ( ) {
532551 this . container . telemetry . sendEvent ( 'home/createBranch' ) ;
0 commit comments