From 983a6909978d2c277e5edf3eee8cb3d509f49a16 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 29 Nov 2017 09:30:17 +0100 Subject: [PATCH] fixes #39271 --- src/vs/platform/list/browser/listService.ts | 9 ++++++++- .../parts/files/electron-browser/views/explorerView.ts | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/vs/platform/list/browser/listService.ts b/src/vs/platform/list/browser/listService.ts index 1fbcc4ba747..b28316f0b5b 100644 --- a/src/vs/platform/list/browser/listService.ts +++ b/src/vs/platform/list/browser/listService.ts @@ -15,6 +15,7 @@ import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { attachListStyler } from 'vs/platform/theme/common/styler'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { debounce } from 'vs/base/common/decorators'; +import Event, { Emitter } from 'vs/base/common/event'; export type ListWidget = List | PagedList | ITree; @@ -142,6 +143,9 @@ export class WorkbenchPagedList extends PagedList { export class WorkbenchTree extends Tree { + private _onFocusChange = new Emitter(); + readonly onFocusChange: Event = this._onFocusChange.event; + readonly contextKeyService: IContextKeyService; private workbenchListFocusContextKey: IContextKey; private disposables: IDisposable[] = []; @@ -172,7 +176,10 @@ export class WorkbenchTree extends Tree { @debounce(50) private updateContextKey(): void { - this.workbenchListFocusContextKey.set(document.activeElement === this.getHTMLElement()); + const isFocused = document.activeElement === this.getHTMLElement(); + + this.workbenchListFocusContextKey.set(isFocused); + this._onFocusChange.fire(isFocused); } dispose(): void { diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts index 4470a9b770a..74b55c0a819 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts @@ -425,8 +425,14 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView }, this.contextKeyService, this.listService, this.themeService); // Bind context keys - FilesExplorerFocusedContext.bindTo(this.explorerViewer.contextKeyService); - ExplorerFocusedContext.bindTo(this.explorerViewer.contextKeyService); + const filesExplorerFocusedContextKey = FilesExplorerFocusedContext.bindTo(this.explorerViewer.contextKeyService); + const explorerFocusedContextKey = ExplorerFocusedContext.bindTo(this.explorerViewer.contextKeyService); + + // Update context keys + this.disposables.push(this.explorerViewer.onFocusChange(focused => { + filesExplorerFocusedContextKey.set(focused); + explorerFocusedContextKey.set(focused); + })); // Update Viewer based on File Change Events this.disposables.push(this.fileService.onAfterOperation(e => this.onFileOperation(e))); -- GitLab