@@ -57,7 +57,8 @@ export class ScmGroupedView implements Disposable {
57
57
}
58
58
59
59
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 } ) ;
61
62
}
62
63
63
64
get view ( ) : TreeViewByType [ GroupableTreeViewTypes ] | undefined {
@@ -126,13 +127,18 @@ export class ScmGroupedView implements Disposable {
126
127
}
127
128
}
128
129
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 ] {
130
134
if ( ! this . views . scmGroupedViews ?. has ( type ) ) {
131
135
type = this . views . scmGroupedViews ?. size ? ( first ( this . views . scmGroupedViews ) as T ) : undefined ! ;
132
136
}
133
137
134
138
void setContext ( 'gitlens:views:scm:grouped:loading' , true ) ;
135
139
clearTimeout ( this . _clearLoadingTimer ) ;
140
+
141
+ const wasVisible = this . _tree ?. visible ?? false ;
136
142
this . resetTree ( ) ;
137
143
138
144
this . _loaded ?. cancel ( ) ;
@@ -143,8 +149,8 @@ export class ScmGroupedView implements Disposable {
143
149
144
150
const view = this . _view ;
145
151
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 } ) ;
148
154
}
149
155
150
156
let selection = this . _lastSelectedByView . get ( type ) ;
@@ -154,19 +160,23 @@ export class ScmGroupedView implements Disposable {
154
160
selection = { node : view . selection [ 0 ] , parents : undefined , expanded : false } ;
155
161
}
156
162
if ( selection == null ) {
157
- if ( focus ) {
163
+ if ( options ?. focus ) {
158
164
await view . show ( { preserveFocus : false } ) ;
159
165
}
160
166
return ;
161
167
}
162
168
163
169
const { node, parents, expanded } = selection ;
164
170
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
+ } ) ;
166
176
} else {
167
177
await view . revealDeep ( node , parents , {
168
178
expand : expanded ,
169
- focus : focus ?? false ,
179
+ focus : options ?. focus ?? false ,
170
180
select : true ,
171
181
} ) ;
172
182
}
@@ -192,6 +202,10 @@ export class ScmGroupedView implements Disposable {
192
202
193
203
this . views . lastSelectedScmGroupedView = type ;
194
204
205
+ if ( ! options ?. preventReveal && ! wasVisible ) {
206
+ void this . _view . show ( { preserveFocus : ! options ?. focus } ) ;
207
+ }
208
+
195
209
return this . _view as TreeViewByType [ T ] ;
196
210
}
197
211
0 commit comments