@@ -90,6 +90,7 @@ export class ListService implements IListService {
9090const RawWorkbenchListFocusContextKey = new RawContextKey < boolean > ( 'listFocus' , true ) ;
9191export const WorkbenchListSupportsMultiSelectContextKey = new RawContextKey < boolean > ( 'listSupportsMultiselect' , true ) ;
9292export const WorkbenchListFocusContextKey = ContextKeyExpr . and ( RawWorkbenchListFocusContextKey , ContextKeyExpr . not ( InputFocusedContextKey ) ) ;
93+ export const WorkbenchListHasSelectionOrFocus = new RawContextKey < boolean > ( 'listHasSelectionOrFocus' , false ) ;
9394export const WorkbenchListDoubleSelection = new RawContextKey < boolean > ( 'listDoubleSelection' , false ) ;
9495export const WorkbenchListMultiSelection = new RawContextKey < boolean > ( 'listMultiSelection' , false ) ;
9596
@@ -199,6 +200,7 @@ export class WorkbenchList<T> extends List<T> {
199200
200201 readonly contextKeyService : IContextKeyService ;
201202
203+ private listHasSelectionOrFocus : IContextKey < boolean > ;
202204 private listDoubleSelection : IContextKey < boolean > ;
203205 private listMultiSelection : IContextKey < boolean > ;
204206
@@ -225,6 +227,7 @@ export class WorkbenchList<T> extends List<T> {
225227 ) ;
226228
227229 this . contextKeyService = createScopedContextKeyService ( contextKeyService , this ) ;
230+ this . listHasSelectionOrFocus = WorkbenchListHasSelectionOrFocus . bindTo ( this . contextKeyService ) ;
228231 this . listDoubleSelection = WorkbenchListDoubleSelection . bindTo ( this . contextKeyService ) ;
229232 this . listMultiSelection = WorkbenchListMultiSelection . bindTo ( this . contextKeyService ) ;
230233
@@ -236,8 +239,17 @@ export class WorkbenchList<T> extends List<T> {
236239 attachListStyler ( this , themeService ) ,
237240 this . onSelectionChange ( ( ) => {
238241 const selection = this . getSelection ( ) ;
242+ const focus = this . getFocus ( ) ;
243+
244+ this . listHasSelectionOrFocus . set ( selection . length > 0 || focus . length > 0 ) ;
239245 this . listMultiSelection . set ( selection . length > 1 ) ;
240246 this . listDoubleSelection . set ( selection . length === 2 ) ;
247+ } ) ,
248+ this . onFocusChange ( ( ) => {
249+ const selection = this . getSelection ( ) ;
250+ const focus = this . getFocus ( ) ;
251+
252+ this . listHasSelectionOrFocus . set ( selection . length > 0 || focus . length > 0 ) ;
241253 } )
242254 ] ) ) ;
243255
@@ -323,6 +335,7 @@ export class WorkbenchTree extends Tree {
323335
324336 protected disposables : IDisposable [ ] ;
325337
338+ private listHasSelectionOrFocus : IContextKey < boolean > ;
326339 private listDoubleSelection : IContextKey < boolean > ;
327340 private listMultiSelection : IContextKey < boolean > ;
328341
@@ -352,6 +365,7 @@ export class WorkbenchTree extends Tree {
352365
353366 this . disposables = [ ] ;
354367 this . contextKeyService = createScopedContextKeyService ( contextKeyService , this ) ;
368+ this . listHasSelectionOrFocus = WorkbenchListHasSelectionOrFocus . bindTo ( this . contextKeyService ) ;
355369 this . listDoubleSelection = WorkbenchListDoubleSelection . bindTo ( this . contextKeyService ) ;
356370 this . listMultiSelection = WorkbenchListMultiSelection . bindTo ( this . contextKeyService ) ;
357371
@@ -366,10 +380,20 @@ export class WorkbenchTree extends Tree {
366380
367381 this . disposables . push ( this . onDidChangeSelection ( ( ) => {
368382 const selection = this . getSelection ( ) ;
383+ const focus = this . getFocus ( ) ;
384+
385+ this . listHasSelectionOrFocus . set ( ( selection && selection . length > 0 ) || ! ! focus ) ;
369386 this . listDoubleSelection . set ( selection && selection . length === 2 ) ;
370387 this . listMultiSelection . set ( selection && selection . length > 1 ) ;
371388 } ) ) ;
372389
390+ this . disposables . push ( this . onDidChangeFocus ( ( ) => {
391+ const selection = this . getSelection ( ) ;
392+ const focus = this . getFocus ( ) ;
393+
394+ this . listHasSelectionOrFocus . set ( ( selection && selection . length > 0 ) || ! ! focus ) ;
395+ } ) ) ;
396+
373397 this . disposables . push ( configurationService . onDidChangeConfiguration ( e => {
374398 if ( e . affectsConfiguration ( openModeSettingKey ) ) {
375399 this . _openOnSingleClick = useSingleClickToOpen ( configurationService ) ;
0 commit comments