Skip to content

Commit c60da32

Browse files
Use the hover delegate in more UI components of Quick Pick (microsoft#201339)
This way we have a consistent hover UI
1 parent 468f6fc commit c60da32

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/vs/platform/quickinput/browser/quickInputList.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
88
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
99
import { AriaRole } from 'vs/base/browser/ui/aria/aria';
1010
import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
11-
import { IHoverWidget } from 'vs/base/browser/ui/iconLabel/iconHoverDelegate';
11+
import { IHoverDelegate, IHoverWidget } from 'vs/base/browser/ui/iconLabel/iconHoverDelegate';
1212
import { IconLabel, IIconLabelValueOptions } from 'vs/base/browser/ui/iconLabel/iconLabel';
1313
import { KeybindingLabel } from 'vs/base/browser/ui/keybindingLabel/keybindingLabel';
1414
import { IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
@@ -234,7 +234,10 @@ class ListElementRenderer implements IListRenderer<IListElement, IListElementTem
234234

235235
static readonly ID = 'listelement';
236236

237-
constructor(private readonly themeService: IThemeService) { }
237+
constructor(
238+
private readonly themeService: IThemeService,
239+
private readonly hoverDelegate: IHoverDelegate | undefined,
240+
) { }
238241

239242
get templateId() {
240243
return ListElementRenderer.ID;
@@ -266,7 +269,7 @@ class ListElementRenderer implements IListRenderer<IListElement, IListElementTem
266269
const row2 = dom.append(rows, $('.quick-input-list-row'));
267270

268271
// Label
269-
data.label = new IconLabel(row1, { supportHighlights: true, supportDescriptionHighlights: true, supportIcons: true });
272+
data.label = new IconLabel(row1, { supportHighlights: true, supportDescriptionHighlights: true, supportIcons: true, hoverDelegate: this.hoverDelegate });
270273
data.toDisposeTemplate.push(data.label);
271274
data.icon = <HTMLInputElement>dom.prepend(data.label.element, $('.quick-input-list-icon'));
272275

@@ -276,14 +279,14 @@ class ListElementRenderer implements IListRenderer<IListElement, IListElementTem
276279

277280
// Detail
278281
const detailContainer = dom.append(row2, $('.quick-input-list-label-meta'));
279-
data.detail = new IconLabel(detailContainer, { supportHighlights: true, supportIcons: true });
282+
data.detail = new IconLabel(detailContainer, { supportHighlights: true, supportIcons: true, hoverDelegate: this.hoverDelegate });
280283
data.toDisposeTemplate.push(data.detail);
281284

282285
// Separator
283286
data.separator = dom.append(data.entry, $('.quick-input-list-separator'));
284287

285288
// Actions
286-
data.actionBar = new ActionBar(data.entry);
289+
data.actionBar = new ActionBar(data.entry, this.hoverDelegate ? { hoverDelegate: this.hoverDelegate } : undefined);
287290
data.actionBar.domNode.classList.add('quick-input-list-entry-action-bar');
288291
data.toDisposeTemplate.push(data.actionBar);
289292

@@ -313,7 +316,8 @@ class ListElementRenderer implements IListRenderer<IListElement, IListElementTem
313316
// Label
314317
const options: IIconLabelValueOptions = {
315318
matches: labelHighlights || [],
316-
descriptionTitle: element.saneDescription,
319+
// If we have a tooltip, we want that to be shown and not any other hover
320+
descriptionTitle: element.saneTooltip ? undefined : element.saneDescription,
317321
descriptionMatches: descriptionHighlights || [],
318322
labelEscapeNewLines: true
319323
};
@@ -335,7 +339,8 @@ class ListElementRenderer implements IListRenderer<IListElement, IListElementTem
335339
data.detail.element.style.display = '';
336340
data.detail.setLabel(element.saneDetail, undefined, {
337341
matches: detailHighlights,
338-
title: element.saneDetail,
342+
// If we have a tooltip, we want that to be shown and not any other hover
343+
title: element.saneTooltip ? undefined : element.saneDetail,
339344
labelEscapeNewLines: true
340345
});
341346
} else {
@@ -450,7 +455,7 @@ export class QuickInputList {
450455
this.container = dom.append(this.parent, $('.quick-input-list'));
451456
const delegate = new ListElementDelegate();
452457
const accessibilityProvider = new QuickInputAccessibilityProvider();
453-
this.list = options.createList('QuickInput', this.container, delegate, [new ListElementRenderer(themeService)], {
458+
this.list = options.createList('QuickInput', this.container, delegate, [new ListElementRenderer(themeService, options.hoverDelegate)], {
454459
identityProvider: {
455460
getId: element => {
456461
// always prefer item over separator because if item is defined, it must be the main item type

0 commit comments

Comments
 (0)