@@ -57,7 +57,8 @@ export class ScmGroupedView implements Disposable {
5757 }
5858
5959 private onReady ( ) {
60- this . _view = this . setView ( this . views . lastSelectedScmGroupedView ! ) ;
60+ // Since we don't want the view to open on every load, prevent revealing it
61+ this . _view = this . setView ( this . views . lastSelectedScmGroupedView ! , { focus : false , preventReveal : true } ) ;
6162 }
6263
6364 get view ( ) : TreeViewByType [ GroupableTreeViewTypes ] | undefined {
@@ -126,13 +127,18 @@ export class ScmGroupedView implements Disposable {
126127 }
127128 }
128129
129- setView < T extends GroupableTreeViewTypes > ( type : T , focus ?: boolean ) : TreeViewByType [ T ] {
130+ setView < T extends GroupableTreeViewTypes > (
131+ type : T ,
132+ options ?: { focus ?: boolean ; preventReveal ?: boolean } ,
133+ ) : TreeViewByType [ T ] {
130134 if ( ! this . views . scmGroupedViews ?. has ( type ) ) {
131135 type = this . views . scmGroupedViews ?. size ? ( first ( this . views . scmGroupedViews ) as T ) : undefined ! ;
132136 }
133137
134138 void setContext ( 'gitlens:views:scm:grouped:loading' , true ) ;
135139 clearTimeout ( this . _clearLoadingTimer ) ;
140+
141+ const wasVisible = this . _tree ?. visible ?? false ;
136142 this . resetTree ( ) ;
137143
138144 this . _loaded ?. cancel ( ) ;
@@ -143,8 +149,8 @@ export class ScmGroupedView implements Disposable {
143149
144150 const view = this . _view ;
145151 if ( view != null ) {
146- if ( ! view . visible ) {
147- await view . show ( { preserveFocus : ! focus } ) ;
152+ if ( ! options ?. preventReveal && ! view . visible ) {
153+ await view . show ( { preserveFocus : ! options ?. focus } ) ;
148154 }
149155
150156 let selection = this . _lastSelectedByView . get ( type ) ;
@@ -154,19 +160,23 @@ export class ScmGroupedView implements Disposable {
154160 selection = { node : view . selection [ 0 ] , parents : undefined , expanded : false } ;
155161 }
156162 if ( selection == null ) {
157- if ( focus ) {
163+ if ( options ?. focus ) {
158164 await view . show ( { preserveFocus : false } ) ;
159165 }
160166 return ;
161167 }
162168
163169 const { node, parents, expanded } = selection ;
164170 if ( parents == null ) {
165- await view . revealDeep ( node , { expand : expanded , focus : focus ?? false , select : true } ) ;
171+ await view . revealDeep ( node , {
172+ expand : expanded ,
173+ focus : options ?. focus ?? false ,
174+ select : true ,
175+ } ) ;
166176 } else {
167177 await view . revealDeep ( node , parents , {
168178 expand : expanded ,
169- focus : focus ?? false ,
179+ focus : options ?. focus ?? false ,
170180 select : true ,
171181 } ) ;
172182 }
@@ -192,6 +202,10 @@ export class ScmGroupedView implements Disposable {
192202
193203 this . views . lastSelectedScmGroupedView = type ;
194204
205+ if ( ! options ?. preventReveal && ! wasVisible ) {
206+ void this . _view . show ( { preserveFocus : ! options ?. focus } ) ;
207+ }
208+
195209 return this . _view as TreeViewByType [ T ] ;
196210 }
197211
0 commit comments