@@ -38,7 +38,7 @@ import { IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/comm
38
38
import { renderSCMHistoryItemGraph , historyItemGroupLocal , historyItemGroupRemote , historyItemGroupBase , historyItemGroupHoverLabelForeground , toISCMHistoryItemViewModelArray , SWIMLANE_WIDTH , renderSCMHistoryGraphPlaceholder } from 'vs/workbench/contrib/scm/browser/scmHistory' ;
39
39
import { RepositoryActionRunner } from 'vs/workbench/contrib/scm/browser/scmRepositoryRenderer' ;
40
40
import { collectContextMenuActions , connectPrimaryMenu , getActionViewItemProvider , isSCMHistoryItemLoadMoreTreeElement , isSCMHistoryItemViewModelTreeElement , isSCMRepository , isSCMViewService } from 'vs/workbench/contrib/scm/browser/util' ;
41
- import { ISCMHistoryItem , ISCMHistoryItemViewModel , SCMHistoryItemLoadMoreTreeElement , SCMHistoryItemViewModelTreeElement } from 'vs/workbench/contrib/scm/common/history' ;
41
+ import { ISCMHistoryItem , ISCMHistoryItemGroup , ISCMHistoryItemViewModel , SCMHistoryItemLoadMoreTreeElement , SCMHistoryItemViewModelTreeElement } from 'vs/workbench/contrib/scm/common/history' ;
42
42
import { HISTORY_VIEW_PANE_ID , ISCMProvider , ISCMRepository , ISCMViewService , ISCMViewVisibleRepositoryChangeEvent } from 'vs/workbench/contrib/scm/common/scm' ;
43
43
import { IListAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget' ;
44
44
import { stripIcons } from 'vs/base/common/iconLabels' ;
@@ -237,8 +237,11 @@ class HistoryItemRenderer implements ITreeRenderer<SCMHistoryItemViewModelTreeEl
237
237
const instantHoverDelegate = createInstantHoverDelegate ( ) ;
238
238
templateData . elementDisposables . add ( instantHoverDelegate ) ;
239
239
240
+ // Get lits of labels to render (current, remote, base)
241
+ const labels = this . getLabels ( node . element . repository ) ;
242
+
240
243
for ( const label of historyItem . labels ) {
241
- if ( label . icon && ThemeIcon . isThemeIcon ( label . icon ) ) {
244
+ if ( label . icon && ThemeIcon . isThemeIcon ( label . icon ) && labels . includes ( label . title ) ) {
242
245
const icon = append ( templateData . labelContainer , $ ( 'div.label' ) ) ;
243
246
icon . classList . add ( ...ThemeIcon . asClassNameArray ( label . icon ) ) ;
244
247
@@ -249,6 +252,15 @@ class HistoryItemRenderer implements ITreeRenderer<SCMHistoryItemViewModelTreeEl
249
252
}
250
253
}
251
254
255
+ private getLabels ( repository : ISCMRepository ) : string [ ] {
256
+ const currentHistoryItemGroup = repository . provider . historyProvider . get ( ) ?. currentHistoryItemGroup . get ( ) ;
257
+ if ( ! currentHistoryItemGroup ) {
258
+ return [ ] ;
259
+ }
260
+
261
+ return [ currentHistoryItemGroup . name , currentHistoryItemGroup . remote ?. name ?? '' , currentHistoryItemGroup . base ?. name ?? '' ] ;
262
+ }
263
+
252
264
private getTooltip ( element : SCMHistoryItemViewModelTreeElement ) : IManagedHoverTooltipMarkdownString {
253
265
const colorTheme = this . themeService . getColorTheme ( ) ;
254
266
const historyItem = element . historyItemViewModel . historyItem ;
@@ -519,10 +531,10 @@ class SCMHistoryTreeKeyboardNavigationLabelProvider implements IKeyboardNavigati
519
531
}
520
532
}
521
533
522
- type HistoryItemCacheEntry = { items : ISCMHistoryItem [ ] ; loadMore : boolean } ;
534
+ type HistoryItemState = { currentHistoryItemGroup : ISCMHistoryItemGroup ; items : ISCMHistoryItem [ ] ; loadMore : boolean } ;
523
535
524
536
class SCMHistoryTreeDataSource extends Disposable implements IAsyncDataSource < ISCMViewService , TreeElement > {
525
- private readonly _historyItems = new Map < ISCMRepository , HistoryItemCacheEntry > ( ) ;
537
+ private readonly _state = new Map < ISCMRepository , HistoryItemState > ( ) ;
526
538
527
539
constructor (
528
540
@IConfigurationService private readonly _configurationService : IConfigurationService ,
@@ -572,47 +584,56 @@ class SCMHistoryTreeDataSource extends Disposable implements IAsyncDataSource<IS
572
584
}
573
585
}
574
586
575
- clearCache ( repository ?: ISCMRepository ) : void {
587
+ clearState ( repository ?: ISCMRepository ) : void {
576
588
if ( ! repository ) {
577
- this . _historyItems . clear ( ) ;
589
+ this . _state . clear ( ) ;
578
590
return ;
579
591
}
580
592
581
- this . _historyItems . delete ( repository ) ;
593
+ this . _state . delete ( repository ) ;
594
+ }
595
+
596
+ getState ( repository : ISCMRepository ) : HistoryItemState | undefined {
597
+ return this . _state . get ( repository ) ;
582
598
}
583
599
584
600
loadMore ( repository : ISCMRepository ) : void {
585
- const entry = this . _historyItems . get ( repository ) ;
586
- this . _historyItems . set ( repository , { items : entry ?. items ?? [ ] , loadMore : true } ) ;
601
+ const state = this . _state . get ( repository ) ;
602
+ if ( ! state ) {
603
+ return ;
604
+ }
605
+
606
+ this . _state . set ( repository , { ...state , loadMore : true } ) ;
587
607
}
588
608
589
609
private async _getHistoryItems ( element : ISCMRepository ) : Promise < SCMHistoryItemViewModelTreeElement [ ] > {
610
+ let state = this . _state . get ( element ) ;
590
611
const historyProvider = element . provider . historyProvider . get ( ) ;
591
- const currentHistoryItemGroup = historyProvider ?. currentHistoryItemGroup . get ( ) ;
612
+ const currentHistoryItemGroup = state ?. currentHistoryItemGroup ?? historyProvider ?. currentHistoryItemGroup . get ( ) ;
592
613
593
614
if ( ! historyProvider || ! currentHistoryItemGroup ) {
594
615
return [ ] ;
595
616
}
596
617
597
- let historyItemsCacheEntry = this . _historyItems . get ( element ) ;
598
- if ( ! historyItemsCacheEntry || historyItemsCacheEntry . loadMore ) {
618
+ if ( ! state || state . loadMore ) {
599
619
const historyItemGroupIds = [
600
- currentHistoryItemGroup . id ,
601
- ...currentHistoryItemGroup . remote ? [ currentHistoryItemGroup . remote . id ] : [ ] ,
602
- ...currentHistoryItemGroup . base ? [ currentHistoryItemGroup . base . id ] : [ ] ,
620
+ currentHistoryItemGroup . revision ?? currentHistoryItemGroup . id ,
621
+ ...currentHistoryItemGroup . remote ? [ currentHistoryItemGroup . remote . revision ?? currentHistoryItemGroup . remote . id ] : [ ] ,
622
+ ...currentHistoryItemGroup . base ? [ currentHistoryItemGroup . base . revision ?? currentHistoryItemGroup . base . id ] : [ ] ,
603
623
] ;
604
624
605
- const existingHistoryItems = historyItemsCacheEntry ?. items ?? [ ] ;
625
+ const existingHistoryItems = state ?. items ?? [ ] ;
606
626
const historyItems = await historyProvider . provideHistoryItems2 ( {
607
627
historyItemGroupIds, limit : 50 , skip : existingHistoryItems . length
608
628
} ) ?? [ ] ;
609
629
610
- historyItemsCacheEntry = {
630
+ state = {
631
+ currentHistoryItemGroup,
611
632
items : [ ...existingHistoryItems , ...historyItems ] ,
612
633
loadMore : false
613
634
} ;
614
635
615
- this . _historyItems . set ( element , historyItemsCacheEntry ) ;
636
+ this . _state . set ( element , state ) ;
616
637
}
617
638
618
639
// Create the color map
@@ -626,7 +647,7 @@ class SCMHistoryTreeDataSource extends Disposable implements IAsyncDataSource<IS
626
647
colorMap . set ( currentHistoryItemGroup . base . name , historyItemGroupBase ) ;
627
648
}
628
649
629
- return toISCMHistoryItemViewModelArray ( historyItemsCacheEntry . items , colorMap )
650
+ return toISCMHistoryItemViewModelArray ( state . items , colorMap )
630
651
. map ( historyItemViewModel => ( {
631
652
repository : element ,
632
653
historyItemViewModel,
@@ -635,7 +656,7 @@ class SCMHistoryTreeDataSource extends Disposable implements IAsyncDataSource<IS
635
656
}
636
657
637
658
override dispose ( ) : void {
638
- this . _historyItems . clear ( ) ;
659
+ this . _state . clear ( ) ;
639
660
super . dispose ( ) ;
640
661
}
641
662
}
@@ -721,15 +742,15 @@ export class SCMHistoryViewPane extends ViewPane {
721
742
this . _tree . scrollTop = 0 ;
722
743
} ) ;
723
744
} else {
724
- this . _treeDataSource . clearCache ( ) ;
745
+ this . _treeDataSource . clearState ( ) ;
725
746
this . _visibilityDisposables . clear ( ) ;
726
747
this . _repositories . clearAndDisposeAll ( ) ;
727
748
}
728
749
} ) ;
729
750
}
730
751
731
752
async refresh ( repository ?: ISCMRepository ) : Promise < void > {
732
- this . _treeDataSource . clearCache ( repository ) ;
753
+ this . _treeDataSource . clearState ( repository ) ;
733
754
this . _updateChildren ( repository ) ;
734
755
735
756
this . _tree . scrollTop = 0 ;
@@ -857,7 +878,7 @@ export class SCMHistoryViewPane extends ViewPane {
857
878
}
858
879
859
880
this . _tree . scrollTop = 0 ;
860
- this . _treeDataSource . clearCache ( repository ) ;
881
+ this . _treeDataSource . clearState ( repository ) ;
861
882
this . _updateChildren ( repository ) ;
862
883
} ) ) ;
863
884
@@ -866,7 +887,7 @@ export class SCMHistoryViewPane extends ViewPane {
866
887
867
888
// Removed repositories
868
889
for ( const repository of removed ) {
869
- this . _treeDataSource . clearCache ( repository ) ;
890
+ this . _treeDataSource . clearState ( repository ) ;
870
891
this . _repositories . deleteAndDispose ( repository ) ;
871
892
}
872
893
@@ -906,7 +927,6 @@ export class SCMHistoryViewPane extends ViewPane {
906
927
await this . _tree . updateChildren ( element , undefined , undefined , {
907
928
// diffIdentityProvider: this._treeIdentityProvider
908
929
} ) ;
909
- //}
910
930
} else {
911
931
// Refresh the entire tree
912
932
await this . _tree . updateChildren ( undefined , undefined , undefined , {
0 commit comments