Skip to content

Commit

Permalink
Custom hover keeps lingering around (#106228)
Browse files Browse the repository at this point in the history
@Tyriar has fixed this for the September release, but for August we will not use the custom hover in the custom tree view by default. This change is mostly a revert of 874c98d. In the September iteration, we will go back to using custom hovers by default in the custom tree view.
Fixes #106096
  • Loading branch information
alexr00 authored Sep 7, 2020
1 parent e4256dd commit f7c5fc7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/vs/workbench/contrib/views/browser/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import { isFalsyOrWhitespace } from 'vs/base/common/strings';
import { SIDE_BAR_BACKGROUND, PANEL_BACKGROUND } from 'vs/workbench/common/theme';
import { IHoverService, IHoverOptions, IHoverTarget } from 'vs/workbench/services/hover/browser/hover';
import { ActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { isMacintosh } from 'vs/base/common/platform';

class Root implements ITreeItem {
Expand Down Expand Up @@ -756,6 +755,8 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
}) : undefined;
const icon = this.themeService.getColorTheme().type === LIGHT ? node.icon : node.iconDark;
const iconUrl = icon ? URI.revive(icon) : null;
const canResolve = node instanceof ResolvableTreeItem && node.hasResolve;
const title = node.tooltip ? (isString(node.tooltip) ? node.tooltip : undefined) : (resource ? undefined : (canResolve ? undefined : label));

// reset
templateData.actionBar.clear();
Expand All @@ -765,7 +766,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
const labelResource = resource ? resource : URI.parse('missing:_icon_resource');
templateData.resourceLabel.setResource({ name: label, description, resource: labelResource }, {
fileKind: this.getFileKind(node),
title: '',
title,
hideIcon: !!iconUrl,
fileDecorations,
extraClasses: ['custom-view-tree-node-item-resourceLabel'],
Expand All @@ -775,7 +776,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
fallbackHover = this.labelService.getUriLabel(labelResource);
} else {
templateData.resourceLabel.setResource({ name: label, description }, {
title: '',
title,
hideIcon: true,
extraClasses: ['custom-view-tree-node-item-resourceLabel'],
matches: matches ? matches : createMatches(element.filterData),
Expand Down Expand Up @@ -810,6 +811,11 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
}

private setupHovers(node: ITreeItem, htmlElement: HTMLElement, disposableStore: DisposableStore, label: string | undefined): void {
if (!(node instanceof ResolvableTreeItem) || (node.tooltip && isString(node.tooltip)) || (!node.tooltip && !node.hasResolve)) {
return;
}
const resolvableNode: ResolvableTreeItem = node;

const hoverService = this.hoverService;
// Testing has indicated that on Windows and Linux 500 ms matches the native hovers most closely.
// On Mac, the delay is 1500.
Expand All @@ -827,10 +833,8 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
this.addEventListener(DOM.EventType.MOUSE_LEAVE, mouseLeave, { passive: true });
this.addEventListener(DOM.EventType.MOUSE_MOVE, mouseMove, { passive: true });
setTimeout(async () => {
if (node instanceof ResolvableTreeItem) {
await node.resolve();
}
let tooltip: IMarkdownString | string | undefined = node.tooltip ?? label;
await resolvableNode.resolve();
const tooltip = resolvableNode.tooltip ?? label;
if (isHovering && tooltip) {
if (!hoverOptions) {
const target: IHoverTarget = {
Expand Down

0 comments on commit f7c5fc7

Please sign in to comment.