Skip to content

Commit

Permalink
Fix context menu with hover (#174597)
Browse files Browse the repository at this point in the history
  • Loading branch information
lramos15 authored Feb 16, 2023
1 parent 3bc8407 commit 524f422
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/vs/base/browser/ui/iconLabel/iconLabelHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export function setupCustomHover(hoverDelegate: IHoverDelegate, htmlElement: HTM
let hoverWidget: UpdatableHoverWidget | undefined;

const hideHover = (disposeWidget: boolean, disposePreparation: boolean) => {
const hadHover = hoverWidget !== undefined;
if (disposeWidget) {
hoverWidget?.dispose();
hoverWidget = undefined;
Expand All @@ -172,7 +173,9 @@ export function setupCustomHover(hoverDelegate: IHoverDelegate, htmlElement: HTM
hoverPreparation?.dispose();
hoverPreparation = undefined;
}
hoverDelegate.onDidHideHover?.();
if (hadHover) {
hoverDelegate.onDidHideHover?.();
}
};

const triggerShowHover = (delay: number, focus?: boolean, target?: IHoverDelegateTarget) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu

get delay() {
// Delay implementation borrowed froms src/vs/workbench/browser/parts/statusbar/statusbarPart.ts
if (Date.now() - this.lastHoverHideTime < 200) {
if (Date.now() - this.lastHoverHideTime < 500) {
return 0; // show instantly when a hover was recently shown
}

Expand Down Expand Up @@ -317,7 +317,8 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
overflowed = width <= childWidth;
}

const hasDecoration = element.classList.toString().includes('monaco-decoration-iconBadge');
// Only count decorations that provide additional info, as hover overing decorations such as git excluded isn't helpful
const hasDecoration = options.content.toString().includes('•');
// If it's overflowing or has a decoration show the tooltip
overflowed = overflowed || hasDecoration;

Expand All @@ -330,6 +331,7 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
...options,
target: indentGuideElement,
compact: true,
container: row,
additionalClasses: ['explorer-item-hover'],
skipFadeInAnimation: true,
showPointer: false,
Expand Down

0 comments on commit 524f422

Please sign in to comment.