From 66ab6580ea8053cd744da49d4e4a7c522ba36f88 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 8 Sep 2020 15:48:35 +0200 Subject: [PATCH] Add back hideHover and use on tree context menu show Fixes #106268 --- src/vs/workbench/contrib/views/browser/treeView.ts | 4 +++- src/vs/workbench/services/hover/browser/hover.ts | 5 +++++ src/vs/workbench/services/hover/browser/hoverService.ts | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/views/browser/treeView.ts b/src/vs/workbench/contrib/views/browser/treeView.ts index 64a90c8d0b6..14b2776a967 100644 --- a/src/vs/workbench/contrib/views/browser/treeView.ts +++ b/src/vs/workbench/contrib/views/browser/treeView.ts @@ -113,6 +113,7 @@ export class TreeView extends Disposable implements ITreeView { @IKeybindingService private readonly keybindingService: IKeybindingService, @INotificationService private readonly notificationService: INotificationService, @IViewDescriptorService private readonly viewDescriptorService: IViewDescriptorService, + @IHoverService private readonly hoverService: IHoverService, @IContextKeyService contextKeyService: IContextKeyService ) { super(); @@ -434,6 +435,7 @@ export class TreeView extends Disposable implements ITreeView { } private onContextMenu(treeMenus: TreeMenus, treeEvent: ITreeContextMenuEvent, actionRunner: MultipleSelectionActionRunner): void { + this.hoverService.hideHover(); const node: ITreeItem | null = treeEvent.element; if (node === null) { return; @@ -1026,7 +1028,7 @@ export class CustomTreeView extends TreeView { @IHoverService hoverService: IHoverService, @IExtensionService private readonly extensionService: IExtensionService, ) { - super(id, title, themeService, instantiationService, commandService, configurationService, progressService, contextMenuService, keybindingService, notificationService, viewDescriptorService, contextKeyService); + super(id, title, themeService, instantiationService, commandService, configurationService, progressService, contextMenuService, keybindingService, notificationService, viewDescriptorService, hoverService, contextKeyService); } setVisibility(isVisible: boolean): void { diff --git a/src/vs/workbench/services/hover/browser/hover.ts b/src/vs/workbench/services/hover/browser/hover.ts index 9bf40ada030..af6473009e7 100644 --- a/src/vs/workbench/services/hover/browser/hover.ts +++ b/src/vs/workbench/services/hover/browser/hover.ts @@ -30,6 +30,11 @@ export interface IHoverService { * ``` */ showHover(options: IHoverOptions, focus?: boolean): IDisposable | undefined; + + /** + * Hides the hover if it was visible. + */ + hideHover(): void; } export interface IHoverOptions { diff --git a/src/vs/workbench/services/hover/browser/hoverService.ts b/src/vs/workbench/services/hover/browser/hoverService.ts index 30684fc337a..28809ada167 100644 --- a/src/vs/workbench/services/hover/browser/hoverService.ts +++ b/src/vs/workbench/services/hover/browser/hoverService.ts @@ -47,6 +47,14 @@ export class HoverService implements IHoverService { return hover; } + hideHover(): void { + if (!this._currentHoverOptions) { + return; + } + this._currentHoverOptions = undefined; + this._contextViewService.hideContextView(); + } + private _intersectionChange(entries: IntersectionObserverEntry[], hover: IDisposable): void { const entry = entries[entries.length - 1]; if (!entry.isIntersecting) {