Skip to content

Commit

Permalink
Add back hideHover and use on tree context menu show
Browse files Browse the repository at this point in the history
Fixes #106268
  • Loading branch information
alexr00 committed Sep 8, 2020
1 parent 2edbe68 commit 66ab658
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/vs/workbench/contrib/views/browser/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -434,6 +435,7 @@ export class TreeView extends Disposable implements ITreeView {
}

private onContextMenu(treeMenus: TreeMenus, treeEvent: ITreeContextMenuEvent<ITreeItem>, actionRunner: MultipleSelectionActionRunner): void {
this.hoverService.hideHover();
const node: ITreeItem | null = treeEvent.element;
if (node === null) {
return;
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/services/hover/browser/hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions src/vs/workbench/services/hover/browser/hoverService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 66ab658

Please sign in to comment.