@@ -2294,7 +2294,6 @@ export class SCMViewPane extends ViewPane {
2294
2294
private treeScrollTop : number | undefined ;
2295
2295
private treeContainer ! : HTMLElement ;
2296
2296
private tree ! : WorkbenchCompressibleAsyncDataTree < ISCMViewService , TreeElement , FuzzyScore > ;
2297
- private treeDataSource ! : SCMTreeDataSource ;
2298
2297
2299
2298
private listLabels ! : ResourceLabels ;
2300
2299
private inputRenderer ! : InputRenderer ;
@@ -2529,7 +2528,8 @@ export class SCMViewPane extends ViewPane {
2529
2528
actionRunner . onWillRun ( ( ) => this . tree . domFocus ( ) , this , this . disposables ) ;
2530
2529
this . disposables . add ( actionRunner ) ;
2531
2530
2532
- this . treeDataSource = this . instantiationService . createInstance ( SCMTreeDataSource , ( ) => this . viewMode , ( ) => this . alwaysShowRepositories , ( ) => this . showActionButton , ( ) => this . showIncomingChanges , ( ) => this . showOutgoingChanges ) ;
2531
+ const treeDataSource = this . instantiationService . createInstance ( SCMTreeDataSource , ( ) => this . viewMode , ( ) => this . alwaysShowRepositories , ( ) => this . showActionButton , ( ) => this . showIncomingChanges , ( ) => this . showOutgoingChanges ) ;
2532
+ this . disposables . add ( treeDataSource ) ;
2533
2533
2534
2534
this . tree = this . instantiationService . createInstance (
2535
2535
WorkbenchCompressibleAsyncDataTree ,
@@ -2548,7 +2548,7 @@ export class SCMViewPane extends ViewPane {
2548
2548
this . instantiationService . createInstance ( HistoryItemChangeRenderer , ( ) => this . viewMode , this . listLabels ) ,
2549
2549
this . instantiationService . createInstance ( SeparatorRenderer )
2550
2550
] ,
2551
- this . treeDataSource ,
2551
+ treeDataSource ,
2552
2552
{
2553
2553
horizontalScrolling : false ,
2554
2554
setRowLineHeight : false ,
@@ -2717,10 +2717,7 @@ export class SCMViewPane extends ViewPane {
2717
2717
} ) ) ;
2718
2718
2719
2719
if ( repository . provider . historyProvider ) {
2720
- repositoryDisposables . add ( repository . provider . historyProvider . onDidChangeCurrentHistoryItemGroup ( ( ) => {
2721
- this . treeDataSource . deleteCacheEntry ( repository ) ;
2722
- this . updateChildren ( repository ) ;
2723
- } ) ) ;
2720
+ repositoryDisposables . add ( repository . provider . historyProvider . onDidChangeCurrentHistoryItemGroup ( ( ) => this . updateChildren ( repository ) ) ) ;
2724
2721
}
2725
2722
2726
2723
const resourceGroupDisposables = repositoryDisposables . add ( new DisposableMap < ISCMResourceGroup , IDisposable > ( ) ) ;
@@ -2754,7 +2751,6 @@ export class SCMViewPane extends ViewPane {
2754
2751
2755
2752
// Removed repositories
2756
2753
for ( const repository of removed ) {
2757
- this . treeDataSource . deleteCacheEntry ( repository ) ;
2758
2754
this . items . deleteAndDispose ( repository ) ;
2759
2755
}
2760
2756
@@ -2973,6 +2969,8 @@ export class SCMViewPane extends ViewPane {
2973
2969
class SCMTreeDataSource implements IAsyncDataSource < ISCMViewService , TreeElement > {
2974
2970
2975
2971
private readonly historyProviderCache = new Map < ISCMRepository , ISCMHistoryProviderCacheEntry > ( ) ;
2972
+ private readonly repositoryDisposables = new DisposableMap < ISCMRepository , IDisposable > ( ) ;
2973
+ private readonly disposables = new DisposableStore ( ) ;
2976
2974
2977
2975
constructor (
2978
2976
private readonly viewMode : ( ) => ViewMode ,
@@ -2982,7 +2980,10 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
2982
2980
private readonly showOutgoingChanges : ( ) => ShowChangesSetting ,
2983
2981
@ISCMViewService private readonly scmViewService : ISCMViewService ,
2984
2982
@IUriIdentityService private uriIdentityService : IUriIdentityService ,
2985
- ) { }
2983
+ ) {
2984
+ this . scmViewService . onDidChangeVisibleRepositories ( this . onDidChangeVisibleRepositories , this , this . disposables ) ;
2985
+ this . onDidChangeVisibleRepositories ( { added : this . scmViewService . visibleRepositories , removed : Iterable . empty ( ) } ) ;
2986
+ }
2986
2987
2987
2988
hasChildren ( inputOrElement : ISCMViewService | TreeElement ) : boolean {
2988
2989
if ( isSCMViewService ( inputOrElement ) ) {
@@ -3212,13 +3213,6 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
3212
3213
return children ;
3213
3214
}
3214
3215
3215
- private getHistoryProviderCacheEntry ( repository : ISCMRepository ) : ISCMHistoryProviderCacheEntry {
3216
- return this . historyProviderCache . get ( repository ) ?? {
3217
- historyItems : new Map < string , ISCMHistoryItem [ ] > ( ) ,
3218
- historyItemChanges : new Map < string , ISCMHistoryItemChange [ ] > ( )
3219
- } ;
3220
- }
3221
-
3222
3216
getParent ( element : TreeElement ) : ISCMViewService | TreeElement {
3223
3217
if ( isSCMResourceNode ( element ) ) {
3224
3218
if ( element . parent === element . context . resourceTree . root ) {
@@ -3250,8 +3244,36 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
3250
3244
}
3251
3245
}
3252
3246
3253
- deleteCacheEntry ( repository : ISCMRepository ) : void {
3254
- this . historyProviderCache . delete ( repository ) ;
3247
+ private onDidChangeVisibleRepositories ( { added, removed } : ISCMViewVisibleRepositoryChangeEvent ) : void {
3248
+ // Added repositories
3249
+ for ( const repository of added ) {
3250
+ const repositoryDisposables = new DisposableStore ( ) ;
3251
+
3252
+ if ( repository . provider . historyProvider ) {
3253
+ repositoryDisposables . add ( repository . provider . historyProvider . onDidChangeCurrentHistoryItemGroup ( ( ) => this . historyProviderCache . delete ( repository ) ) ) ;
3254
+ }
3255
+
3256
+ this . repositoryDisposables . set ( repository , repositoryDisposables ) ;
3257
+ }
3258
+
3259
+ // Removed repositories
3260
+ for ( const repository of removed ) {
3261
+ this . repositoryDisposables . deleteAndDispose ( repository ) ;
3262
+ this . historyProviderCache . delete ( repository ) ;
3263
+ }
3264
+ }
3265
+
3266
+ private getHistoryProviderCacheEntry ( repository : ISCMRepository ) : ISCMHistoryProviderCacheEntry {
3267
+ return this . historyProviderCache . get ( repository ) ?? {
3268
+ historyItemGroupDetails : undefined ,
3269
+ historyItems : new Map < string , ISCMHistoryItem [ ] > ( ) ,
3270
+ historyItemChanges : new Map < string , ISCMHistoryItemChange [ ] > ( )
3271
+ } ;
3272
+ }
3273
+
3274
+ dispose ( ) : void {
3275
+ this . repositoryDisposables . dispose ( ) ;
3276
+ this . disposables . dispose ( ) ;
3255
3277
}
3256
3278
}
3257
3279
0 commit comments