@@ -19,7 +19,7 @@ import { IContextViewService, IContextMenuService } from 'vs/platform/contextvie
19
19
import { IContextKeyService , IContextKey , ContextKeyExpr , RawContextKey } from 'vs/platform/contextkey/common/contextkey' ;
20
20
import { ICommandService } from 'vs/platform/commands/common/commands' ;
21
21
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
22
- import { MenuItemAction , IMenuService , registerAction2 , MenuId , IAction2Options , MenuRegistry , Action2 } from 'vs/platform/actions/common/actions' ;
22
+ import { MenuItemAction , IMenuService , registerAction2 , MenuId , IAction2Options , MenuRegistry , Action2 , IMenu } from 'vs/platform/actions/common/actions' ;
23
23
import { IAction , ActionRunner , Action , Separator } from 'vs/base/common/actions' ;
24
24
import { ActionBar , IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar' ;
25
25
import { IThemeService , IFileIconTheme } from 'vs/platform/theme/common/themeService' ;
@@ -356,6 +356,7 @@ interface ResourceTemplate {
356
356
fileLabel : IResourceLabel ;
357
357
decorationIcon : HTMLElement ;
358
358
actionBar : ActionBar ;
359
+ actionBarMenu : IMenu | undefined ;
359
360
readonly elementDisposables : DisposableStore ;
360
361
readonly disposables : IDisposable ;
361
362
}
@@ -419,7 +420,7 @@ class ResourceRenderer implements ICompressibleTreeRenderer<ISCMResource | IReso
419
420
const decorationIcon = append ( element , $ ( '.decoration-icon' ) ) ;
420
421
const disposables = combinedDisposable ( actionBar , fileLabel ) ;
421
422
422
- return { element, name, fileLabel, decorationIcon, actionBar, elementDisposables : new DisposableStore ( ) , disposables } ;
423
+ return { element, name, fileLabel, decorationIcon, actionBar, actionBarMenu : undefined , elementDisposables : new DisposableStore ( ) , disposables } ;
423
424
}
424
425
425
426
renderElement ( node : ITreeNode < ISCMResource , FuzzyScore | LabelFuzzyScore > | ITreeNode < ISCMResource | IResourceNode < ISCMResource , ISCMResourceGroup > , FuzzyScore | LabelFuzzyScore > , index : number , template : ResourceTemplate ) : void {
@@ -430,29 +431,29 @@ class ResourceRenderer implements ICompressibleTreeRenderer<ISCMResource | IReso
430
431
const viewModel = this . viewModelProvider ( ) ;
431
432
const tooltip = ! ResourceTree . isResourceNode ( resourceOrFolder ) && resourceOrFolder . decorations . tooltip || '' ;
432
433
433
- template . actionBar . clear ( ) ;
434
- template . actionBar . context = resourceOrFolder ;
435
-
436
434
let matches : IMatch [ ] | undefined ;
437
435
let descriptionMatches : IMatch [ ] | undefined ;
438
436
let strikethrough : boolean | undefined ;
439
437
440
438
if ( ResourceTree . isResourceNode ( resourceOrFolder ) ) {
441
439
if ( resourceOrFolder . element ) {
442
440
const menus = this . scmViewService . menus . getRepositoryMenus ( resourceOrFolder . element . resourceGroup . provider ) ;
443
- template . elementDisposables . add ( connectPrimaryMenuToInlineActionBar ( menus . getResourceMenu ( resourceOrFolder . element ) , template . actionBar ) ) ;
441
+ this . _renderActionBar ( template , resourceOrFolder , menus . getResourceMenu ( resourceOrFolder . element ) ) ;
442
+
444
443
template . element . classList . toggle ( 'faded' , resourceOrFolder . element . decorations . faded ) ;
445
444
strikethrough = resourceOrFolder . element . decorations . strikeThrough ;
446
445
} else {
447
- matches = createMatches ( node . filterData as FuzzyScore | undefined ) ;
448
446
const menus = this . scmViewService . menus . getRepositoryMenus ( resourceOrFolder . context . provider ) ;
449
- template . elementDisposables . add ( connectPrimaryMenuToInlineActionBar ( menus . getResourceFolderMenu ( resourceOrFolder . context ) , template . actionBar ) ) ;
447
+ this . _renderActionBar ( template , resourceOrFolder , menus . getResourceFolderMenu ( resourceOrFolder . context ) ) ;
448
+
449
+ matches = createMatches ( node . filterData as FuzzyScore | undefined ) ;
450
450
template . element . classList . remove ( 'faded' ) ;
451
451
}
452
452
} else {
453
- [ matches , descriptionMatches ] = this . _processFilterData ( uri , node . filterData ) ;
454
453
const menus = this . scmViewService . menus . getRepositoryMenus ( resourceOrFolder . resourceGroup . provider ) ;
455
- template . elementDisposables . add ( connectPrimaryMenuToInlineActionBar ( menus . getResourceMenu ( resourceOrFolder ) , template . actionBar ) ) ;
454
+ this . _renderActionBar ( template , resourceOrFolder , menus . getResourceMenu ( resourceOrFolder ) ) ;
455
+
456
+ [ matches , descriptionMatches ] = this . _processFilterData ( uri , node . filterData ) ;
456
457
template . element . classList . toggle ( 'faded' , resourceOrFolder . decorations . faded ) ;
457
458
strikethrough = resourceOrFolder . decorations . strikeThrough ;
458
459
}
@@ -497,11 +498,8 @@ class ResourceRenderer implements ICompressibleTreeRenderer<ISCMResource | IReso
497
498
separator : this . labelService . getSeparator ( folder . uri . scheme )
498
499
} ) ;
499
500
500
- template . actionBar . clear ( ) ;
501
- template . actionBar . context = folder ;
502
-
503
501
const menus = this . scmViewService . menus . getRepositoryMenus ( folder . context . provider ) ;
504
- template . elementDisposables . add ( connectPrimaryMenuToInlineActionBar ( menus . getResourceFolderMenu ( folder . context ) , template . actionBar ) ) ;
502
+ this . _renderActionBar ( template , folder , menus . getResourceFolderMenu ( folder . context ) ) ;
505
503
506
504
template . name . classList . remove ( 'strike-through' ) ;
507
505
template . element . classList . remove ( 'faded' ) ;
@@ -520,6 +518,16 @@ class ResourceRenderer implements ICompressibleTreeRenderer<ISCMResource | IReso
520
518
template . disposables . dispose ( ) ;
521
519
}
522
520
521
+ private _renderActionBar ( template : ResourceTemplate , resourceOrFolder : ISCMResource | IResourceNode < ISCMResource , ISCMResourceGroup > , menu : IMenu ) : void {
522
+ if ( ! template . actionBarMenu || template . actionBarMenu !== menu ) {
523
+ template . actionBar . clear ( ) ;
524
+ template . elementDisposables . add ( connectPrimaryMenuToInlineActionBar ( menu , template . actionBar ) ) ;
525
+ template . actionBarMenu = menu ;
526
+ }
527
+
528
+ template . actionBar . context = resourceOrFolder ;
529
+ }
530
+
523
531
private _processFilterData ( uri : URI , filterData : FuzzyScore | LabelFuzzyScore | undefined ) : [ IMatch [ ] | undefined , IMatch [ ] | undefined ] {
524
532
if ( ! filterData ) {
525
533
return [ undefined , undefined ] ;
0 commit comments