@@ -14,6 +14,7 @@ import type { GitWorktree } from '../git/models/worktree';
1414import { executeCommand , executeCoreCommand , registerCommand } from '../system/-webview/command' ;
1515import { configuration } from '../system/-webview/configuration' ;
1616import { getContext , setContext } from '../system/-webview/context' ;
17+ import { getViewFocusCommand } from '../system/-webview/vscode/views' ;
1718import { once } from '../system/function' ;
1819import { first } from '../system/iterable' ;
1920import { compare } from '../system/version' ;
@@ -139,9 +140,9 @@ export class Views implements Disposable {
139140 const disposable = once ( container . onReady ) ( ( ) => {
140141 disposable ?. dispose ( ) ;
141142 setTimeout ( ( ) => {
142- executeCoreCommand ( ` gitlens.views.scm.grouped.focus` , { preserveFocus : true } ) ;
143+ executeCoreCommand ( getViewFocusCommand ( ' gitlens.views.scm.grouped' ) , { preserveFocus : true } ) ;
143144 if ( newInstall ) {
144- executeCoreCommand ( ` gitlens.views.home.focus` , { preserveFocus : true } ) ;
145+ executeCoreCommand ( getViewFocusCommand ( ' gitlens.views.home' ) , { preserveFocus : true } ) ;
145146 }
146147 } , 0 ) ;
147148 } ) ;
@@ -531,6 +532,10 @@ export class Views implements Disposable {
531532
532533 // Restore the last selection for this view type (if any)
533534 if ( view ) {
535+ if ( ! view . visible ) {
536+ await view . show ( { preserveFocus : ! focus } ) ;
537+ }
538+
534539 const selection = this . _lastSelectedByView . get ( type ) ;
535540 if ( selection != null ) {
536541 setTimeout ( async ( ) => {
@@ -549,7 +554,7 @@ export class Views implements Disposable {
549554 this . lastSelectedScmGroupedView = type ;
550555
551556 if ( focus ) {
552- void executeCoreCommand ( ` gitlens.views.scm.grouped.focus` ) ;
557+ void executeCoreCommand ( getViewFocusCommand ( ' gitlens.views.scm.grouped' ) , { preserveFocus : false } ) ;
553558 }
554559
555560 return undefined ;
@@ -597,7 +602,7 @@ export class Views implements Disposable {
597602 await updateScmGroupedViewsInConfig ( this . _scmGroupedViews ) ;
598603
599604 // Show the view after the configuration change has been applied
600- setTimeout ( ( ) => executeCoreCommand ( `gitlens.views.${ grouped ? 'scm.grouped' : type } .focus ` ) , 1 ) ;
605+ setTimeout ( ( ) => executeCoreCommand ( getViewFocusCommand ( `gitlens.views.${ grouped ? 'scm.grouped' : type } ` ) , 1 ) ) ;
601606 }
602607
603608 private toggleScmViewVisibility ( type : GroupableTreeViewTypes , visible : boolean ) {
@@ -988,7 +993,7 @@ export class Views implements Disposable {
988993 case 'workspaces' :
989994 return this . workspaces . show ( ) ;
990995 case 'scm.grouped' :
991- return void executeCoreCommand ( ` gitlens.views.scm.grouped.focus` ) ;
996+ return void executeCoreCommand ( getViewFocusCommand ( ' gitlens.views.scm.grouped' ) ) ;
992997 }
993998 }
994999}
0 commit comments