@@ -28,6 +28,7 @@ import { MenuId } from '../../../../platform/actions/common/actions.js';
28
28
import { IHoverService } from '../../../../platform/hover/browser/hover.js' ;
29
29
import { observableConfigValue } from '../../../../platform/observable/common/platformObservableUtils.js' ;
30
30
import { autorun , IObservable , IObservableSignal , observableSignal , observableSignalFromEvent , runOnChange } from '../../../../base/common/observable.js' ;
31
+ import { Sequencer } from '../../../../base/common/async.js' ;
31
32
32
33
class ListDelegate implements IListVirtualDelegate < ISCMRepository > {
33
34
@@ -101,6 +102,7 @@ export class SCMRepositoriesViewPane extends ViewPane {
101
102
private treeViewModel ! : SCMRepositoriesViewModel ;
102
103
private treeDataSource ! : RepositoryTreeDataSource ;
103
104
private treeIdentityProvider ! : RepositoryTreeIdentityProvider ;
105
+ private readonly treeOperationSequencer = new Sequencer ( ) ;
104
106
105
107
private readonly visibleCountObs : IObservable < number > ;
106
108
private readonly providerCountBadgeObs : IObservable < 'hidden' | 'auto' | 'visible' > ;
@@ -149,32 +151,32 @@ export class SCMRepositoriesViewPane extends ViewPane {
149
151
this . treeViewModel = this . instantiationService . createInstance ( SCMRepositoriesViewModel ) ;
150
152
this . _register ( this . treeViewModel ) ;
151
153
152
- // Initial rendering
153
- await this . tree . setInput ( this . treeViewModel ) ;
154
-
155
- // scm.repositories.visible setting
156
- this . visibilityDisposables . add ( autorun ( reader => {
157
- const visibleCount = this . visibleCountObs . read ( reader ) ;
158
- this . updateBodySize ( visibleCount ) ;
159
- } ) ) ;
160
-
161
- // onDidChangeRepositoriesSignal
162
- this . visibilityDisposables . add ( autorun ( async reader => {
163
- this . treeViewModel . onDidChangeRepositoriesSignal . read ( reader ) ;
164
- await this . updateChildren ( ) ;
165
- } ) ) ;
166
-
167
- // onDidChangeRepositoryContextValueSignal
168
- this . visibilityDisposables . add ( autorun ( async reader => {
169
- this . treeViewModel . onDidChangeRepositoryContextValueSignal . read ( reader ) ;
170
- await this . updateChildren ( ) ;
171
- } ) ) ;
172
-
173
- // onDidChangeVisibleRepositoriesSignal
174
- this . visibilityDisposables . add ( autorun ( async reader => {
175
- this . treeViewModel . onDidChangeVisibleRepositoriesSignal . read ( reader ) ;
176
- this . updateTreeSelection ( ) ;
177
- } ) ) ;
154
+ this . treeOperationSequencer . queue ( async ( ) => {
155
+ // Initial rendering
156
+ await this . tree . setInput ( this . treeViewModel ) ;
157
+
158
+ // scm.repositories.visible setting
159
+ this . visibilityDisposables . add ( autorun ( reader => {
160
+ const visibleCount = this . visibleCountObs . read ( reader ) ;
161
+ this . updateBodySize ( visibleCount ) ;
162
+ } ) ) ;
163
+
164
+ // onDidChangeRepositoriesSignal
165
+ // onDidChangeRepositoryContextValueSignal
166
+ this . visibilityDisposables . add ( autorun ( async reader => {
167
+ this . treeViewModel . onDidChangeRepositoriesSignal . read ( reader ) ;
168
+ this . treeViewModel . onDidChangeRepositoryContextValueSignal . read ( reader ) ;
169
+
170
+ await this . treeOperationSequencer . queue ( ( ) => this . updateChildren ( ) ) ;
171
+ } ) ) ;
172
+
173
+ // onDidChangeVisibleRepositoriesSignal
174
+ this . visibilityDisposables . add ( autorun ( async reader => {
175
+ this . treeViewModel . onDidChangeVisibleRepositoriesSignal . read ( reader ) ;
176
+
177
+ await this . treeOperationSequencer . queue ( async ( ) => this . updateTreeSelection ( ) ) ;
178
+ } ) ) ;
179
+ } ) ;
178
180
} , this , this . _store ) ;
179
181
}
180
182
0 commit comments