@@ -108,6 +108,8 @@ class ActionButtonRenderer implements ICompressibleTreeRenderer<ISCMActionButton
108
108
static readonly TEMPLATE_ID = 'actionButton' ;
109
109
get templateId ( ) : string { return ActionButtonRenderer . TEMPLATE_ID ; }
110
110
111
+ private actionButtons = new Map < ISCMActionButton , SCMActionButton > ( ) ;
112
+
111
113
constructor (
112
114
@ICommandService private commandService : ICommandService ,
113
115
@IContextMenuService private contextMenuService : IContextMenuService ,
@@ -131,13 +133,25 @@ class ActionButtonRenderer implements ICompressibleTreeRenderer<ISCMActionButton
131
133
renderElement ( node : ITreeNode < ISCMActionButton , FuzzyScore > , index : number , templateData : ActionButtonTemplate , height : number | undefined ) : void {
132
134
templateData . disposable . dispose ( ) ;
133
135
136
+ const disposables = new DisposableStore ( ) ;
137
+ const actionButton = node . element ;
134
138
templateData . actionButton . setButton ( node . element . button ) ;
139
+
140
+ // Remember action button
141
+ this . actionButtons . set ( actionButton , templateData . actionButton ) ;
142
+ disposables . add ( { dispose : ( ) => this . actionButtons . delete ( actionButton ) } ) ;
143
+
144
+ templateData . disposable = disposables ;
135
145
}
136
146
137
147
renderCompressedElements ( ) : void {
138
148
throw new Error ( 'Should never happen since node is incompressible' ) ;
139
149
}
140
150
151
+ focusActionButton ( actionButton : ISCMActionButton ) : void {
152
+ this . actionButtons . get ( actionButton ) ?. focus ( ) ;
153
+ }
154
+
141
155
disposeElement ( node : ITreeNode < ISCMActionButton , FuzzyScore > , index : number , template : ActionButtonTemplate ) : void {
142
156
template . disposable . dispose ( ) ;
143
157
}
@@ -2200,6 +2214,7 @@ export class SCMViewPane extends ViewPane {
2200
2214
get viewModel ( ) : ViewModel { return this . _viewModel ; }
2201
2215
private listLabels ! : ResourceLabels ;
2202
2216
private inputRenderer ! : InputRenderer ;
2217
+ private actionButtonRenderer ! : ActionButtonRenderer ;
2203
2218
private readonly disposables = new DisposableStore ( ) ;
2204
2219
2205
2220
constructor (
@@ -2254,6 +2269,8 @@ export class SCMViewPane extends ViewPane {
2254
2269
this . inputRenderer = this . instantiationService . createInstance ( InputRenderer , this . layoutCache , overflowWidgetsDomNode , ( input , height ) => this . tree . updateElementHeight ( input , height ) ) ;
2255
2270
const delegate = new ListDelegate ( this . inputRenderer ) ;
2256
2271
2272
+ this . actionButtonRenderer = this . instantiationService . createInstance ( ActionButtonRenderer ) ;
2273
+
2257
2274
this . listLabels = this . instantiationService . createInstance ( ResourceLabels , { onDidChangeVisibility : this . onDidChangeBodyVisibility } ) ;
2258
2275
this . _register ( this . listLabels ) ;
2259
2276
@@ -2264,7 +2281,7 @@ export class SCMViewPane extends ViewPane {
2264
2281
const renderers : ICompressibleTreeRenderer < any , any , any > [ ] = [
2265
2282
this . instantiationService . createInstance ( RepositoryRenderer , getActionViewItemProvider ( this . instantiationService ) ) ,
2266
2283
this . inputRenderer ,
2267
- this . instantiationService . createInstance ( ActionButtonRenderer ) ,
2284
+ this . actionButtonRenderer ,
2268
2285
this . instantiationService . createInstance ( ResourceGroupRenderer , getActionViewItemProvider ( this . instantiationService ) ) ,
2269
2286
this . _register ( this . instantiationService . createInstance ( ResourceRenderer , ( ) => this . _viewModel , this . listLabels , getActionViewItemProvider ( this . instantiationService ) , actionRunner ) )
2270
2287
] ;
@@ -2394,6 +2411,7 @@ export class SCMViewPane extends ViewPane {
2394
2411
return ;
2395
2412
} else if ( isSCMActionButton ( e . element ) ) {
2396
2413
this . scmViewService . focus ( e . element . repository ) ;
2414
+ this . actionButtonRenderer . focusActionButton ( e . element ) ;
2397
2415
2398
2416
return ;
2399
2417
}
@@ -2663,6 +2681,10 @@ export class SCMActionButton implements IDisposable {
2663
2681
this . disposables . value ! . add ( attachButtonStyler ( this . button , this . themeService ) ) ;
2664
2682
}
2665
2683
2684
+ focus ( ) : void {
2685
+ this . button ?. focus ( ) ;
2686
+ }
2687
+
2666
2688
private clear ( ) : void {
2667
2689
this . disposables . value = new DisposableStore ( ) ;
2668
2690
this . button = undefined ;
0 commit comments