@@ -28,6 +28,7 @@ import { MenuId } from '../../../../platform/actions/common/actions.js';
2828import { IHoverService } from '../../../../platform/hover/browser/hover.js' ;
2929import { observableConfigValue } from '../../../../platform/observable/common/platformObservableUtils.js' ;
3030import { autorun , IObservable , observableSignalFromEvent } from '../../../../base/common/observable.js' ;
31+ import { Sequencer } from '../../../../base/common/async.js' ;
3132
3233class ListDelegate implements IListVirtualDelegate < ISCMRepository > {
3334
@@ -85,6 +86,7 @@ export class SCMRepositoriesViewPane extends ViewPane {
8586 private treeViewModel ! : SCMRepositoriesViewModel ;
8687 private treeDataSource ! : RepositoryTreeDataSource ;
8788 private treeIdentityProvider ! : RepositoryTreeIdentityProvider ;
89+ private readonly treeOperationSequencer = new Sequencer ( ) ;
8890
8991 private readonly visibleCountObs : IObservable < number > ;
9092 private readonly providerCountBadgeObs : IObservable < 'hidden' | 'auto' | 'visible' > ;
@@ -133,26 +135,28 @@ export class SCMRepositoriesViewPane extends ViewPane {
133135 this . treeViewModel = this . instantiationService . createInstance ( SCMRepositoriesViewModel ) ;
134136 this . _register ( this . treeViewModel ) ;
135137
136- // Initial rendering
137- await this . tree . setInput ( this . treeViewModel ) ;
138-
139- // scm.repositories.visible setting
140- this . visibilityDisposables . add ( autorun ( reader => {
141- const visibleCount = this . visibleCountObs . read ( reader ) ;
142- this . updateBodySize ( visibleCount ) ;
143- } ) ) ;
144-
145- // onDidChangeRepositoriesSignal
146- this . visibilityDisposables . add ( autorun ( async reader => {
147- this . treeViewModel . onDidChangeRepositoriesSignal . read ( reader ) ;
148- await this . updateChildren ( ) ;
149- } ) ) ;
150-
151- // onDidChangeVisibleRepositoriesSignal
152- this . visibilityDisposables . add ( autorun ( async reader => {
153- this . treeViewModel . onDidChangeVisibleRepositoriesSignal . read ( reader ) ;
154- this . updateTreeSelection ( ) ;
155- } ) ) ;
138+ this . treeOperationSequencer . queue ( async ( ) => {
139+ // Initial rendering
140+ await this . tree . setInput ( this . treeViewModel ) ;
141+
142+ // scm.repositories.visible setting
143+ this . visibilityDisposables . add ( autorun ( reader => {
144+ const visibleCount = this . visibleCountObs . read ( reader ) ;
145+ this . updateBodySize ( visibleCount ) ;
146+ } ) ) ;
147+
148+ // onDidChangeRepositoriesSignal
149+ this . visibilityDisposables . add ( autorun ( async reader => {
150+ this . treeViewModel . onDidChangeRepositoriesSignal . read ( reader ) ;
151+ await this . treeOperationSequencer . queue ( ( ) => this . updateChildren ( ) ) ;
152+ } ) ) ;
153+
154+ // onDidChangeVisibleRepositoriesSignal
155+ this . visibilityDisposables . add ( autorun ( async reader => {
156+ this . treeViewModel . onDidChangeVisibleRepositoriesSignal . read ( reader ) ;
157+ await this . treeOperationSequencer . queue ( async ( ) => this . updateTreeSelection ( ) ) ;
158+ } ) ) ;
159+ } ) ;
156160 } , this , this . _store ) ;
157161 }
158162
0 commit comments