Skip to content

Commit 8123e64

Browse files
Remove concept of detail in Quick Tree (#260486)
I played around with enabling this but with the twisties, checkbox, icon and all that, I didn't think it looked good. We'll keep `detail` as a Quick Pick feature. fixes #258657
1 parent 6c23f96 commit 8123e64

File tree

9 files changed

+29
-90
lines changed

9 files changed

+29
-90
lines changed

src/vs/platform/quickinput/browser/media/quickInput.css

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
margin: 0;
9595
}
9696

97+
.quick-input-widget .quick-input-header .monaco-checkbox {
98+
margin-top: 6px;
99+
}
100+
97101
.quick-input-filter {
98102
flex-grow: 1;
99103
display: flex;
@@ -211,7 +215,11 @@
211215

212216
.quick-input-widget .monaco-checkbox {
213217
margin-right: 0;
214-
align-self: center;
218+
}
219+
220+
.quick-input-widget .quick-input-list .monaco-checkbox,
221+
.quick-input-widget .quick-input-tree .monaco-checkbox {
222+
margin-top: 4px;
215223
}
216224

217225
.quick-input-list .quick-input-list-icon {
@@ -432,13 +440,6 @@
432440
opacity: 1;
433441
}
434442

435-
.quick-input-tree .quick-input-tree-detail {
436-
opacity: 0.7;
437-
line-height: normal;
438-
text-overflow: ellipsis;
439-
overflow: hidden;
440-
}
441-
442443
.quick-input-tree .quick-input-tree-entry-action-bar {
443444
display: flex;
444445
flex: 0;

src/vs/platform/quickinput/browser/tree/quickInputDelegate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { QuickInputTreeRenderer } from './quickInputTreeRenderer.js';
1111
* Delegate for QuickInputTree that provides height and template information.
1212
*/
1313
export class QuickInputTreeDelegate<T extends IQuickTreeItem> implements IListVirtualDelegate<T> {
14-
getHeight(element: T): number {
15-
return element.detail ? 44 : 22; // 22 for single line, 44 for two lines
14+
getHeight(_element: T): number {
15+
return 22;
1616
}
1717

1818
getTemplateId(_element: T): string {

src/vs/platform/quickinput/browser/tree/quickInputTree.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { IObjectTreeElement, ITreeNode } from '../../../../base/browser/ui/tree/
1010
export interface IQuickTreeFilterData {
1111
readonly labelHighlights?: IMatch[];
1212
readonly descriptionHighlights?: IMatch[];
13-
readonly detailHighlights?: IMatch[];
1413
}
1514

1615
export function getParentNodeState(parentChildren: ITreeNode<IQuickTreeItem | null, IQuickTreeFilterData>[] | IObjectTreeElement<IQuickTreeItem>[]): boolean | 'partial' {

src/vs/platform/quickinput/browser/tree/quickInputTreeAccessibilityProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class QuickTreeAccessibilityProvider<T extends IQuickTreeItem> implements
2020
}
2121

2222
getAriaLabel(element: T): string {
23-
return element.ariaLabel || [element.label, element.description, element.detail]
23+
return element.ariaLabel || [element.label, element.description]
2424
.map(s => getCodiconAriaLabel(s))
2525
.filter(s => !!s)
2626
.join(', ');

src/vs/platform/quickinput/browser/tree/quickInputTreeController.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class QuickInputTreeController extends Disposable {
7575
} else if (a.label > b.label) {
7676
return 1;
7777
}
78-
// use description and then detail to break ties
78+
// use description to break ties
7979
if (a.description && b.description) {
8080
if (a.description < b.description) {
8181
return -1;
@@ -87,17 +87,6 @@ export class QuickInputTreeController extends Disposable {
8787
} else if (b.description) {
8888
return 1;
8989
}
90-
if (a.detail && b.detail) {
91-
if (a.detail < b.detail) {
92-
return -1;
93-
} else if (a.detail > b.detail) {
94-
return 1;
95-
}
96-
} else if (a.detail) {
97-
return -1;
98-
} else if (b.detail) {
99-
return 1;
100-
}
10190
return 0;
10291
}
10392
},
@@ -135,17 +124,13 @@ export class QuickInputTreeController extends Disposable {
135124
updateFilterOptions(options: {
136125
matchOnLabel?: boolean;
137126
matchOnDescription?: boolean;
138-
matchOnDetail?: boolean;
139127
}): void {
140128
if (options.matchOnLabel !== undefined) {
141129
this._filter.matchOnLabel = options.matchOnLabel;
142130
}
143131
if (options.matchOnDescription !== undefined) {
144132
this._filter.matchOnDescription = options.matchOnDescription;
145133
}
146-
if (options.matchOnDetail !== undefined) {
147-
this._filter.matchOnDetail = options.matchOnDetail;
148-
}
149134
this._tree.refilter();
150135
}
151136

src/vs/platform/quickinput/browser/tree/quickInputTreeFilter.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,22 @@ export class QuickInputTreeFilter implements ITreeFilter<IQuickTreeItem, IQuickT
1212
filterValue: string = '';
1313
matchOnLabel: boolean = true;
1414
matchOnDescription: boolean = false;
15-
matchOnDetail: boolean = false;
1615

1716
filter(element: IQuickTreeItem, parentVisibility: TreeVisibility): ITreeFilterDataResult<IQuickTreeFilterData> {
18-
if (!this.filterValue || !(this.matchOnLabel || this.matchOnDescription || this.matchOnDetail)) {
17+
if (!this.filterValue || !(this.matchOnLabel || this.matchOnDescription)) {
1918
return element.children
2019
? { visibility: TreeVisibility.Recurse, data: {} }
2120
: { visibility: TreeVisibility.Visible, data: {} };
2221
}
2322

2423
const labelHighlights = this.matchOnLabel ? matchesFuzzyIconAware(this.filterValue, parseLabelWithIcons(element.label)) ?? undefined : undefined;
2524
const descriptionHighlights = this.matchOnDescription ? matchesFuzzyIconAware(this.filterValue, parseLabelWithIcons(element.description || '')) ?? undefined : undefined;
26-
const detailHighlights = this.matchOnDetail ? matchesFuzzyIconAware(this.filterValue, parseLabelWithIcons(element.detail || '')) ?? undefined : undefined;
2725

2826
const visibility = parentVisibility === TreeVisibility.Visible
2927
// Parent is visible because it had matches, so we show all children
3028
? TreeVisibility.Visible
3129
// This would only happen on Parent is recurse so...
32-
: (labelHighlights || descriptionHighlights || detailHighlights)
30+
: (labelHighlights || descriptionHighlights)
3331
// If we have any highlights, we are visible
3432
? TreeVisibility.Visible
3533
// Otherwise, we defer to the children or if no children, we are hidden
@@ -41,8 +39,7 @@ export class QuickInputTreeFilter implements ITreeFilter<IQuickTreeItem, IQuickT
4139
visibility,
4240
data: {
4341
labelHighlights,
44-
descriptionHighlights,
45-
detailHighlights
42+
descriptionHighlights
4643
}
4744
};
4845
}

src/vs/platform/quickinput/browser/tree/quickInputTreeRenderer.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export interface IQuickTreeTemplateData {
2929
checkbox: TriStateCheckbox;
3030
icon: HTMLElement;
3131
label: IconLabel;
32-
detail: IconLabel;
3332
actionBar: ActionBar;
3433
toDisposeElement: DisposableStore;
3534
toDisposeTemplate: DisposableStore;
@@ -67,13 +66,6 @@ export class QuickInputTreeRenderer<T extends IQuickTreeItem> extends Disposable
6766
supportIcons: true,
6867
hoverDelegate: this._hoverDelegate
6968
}));
70-
const row2 = dom.append(rows, $('.quick-input-tree-row'));
71-
const detailContainer = dom.append(row2, $('.quick-input-tree-detail'));
72-
const detail = store.add(new IconLabel(detailContainer, {
73-
supportHighlights: true,
74-
supportIcons: true,
75-
hoverDelegate: this._hoverDelegate
76-
}));
7769
const actionBar = store.add(new ActionBar(entry, this._hoverDelegate ? { hoverDelegate: this._hoverDelegate } : undefined));
7870
actionBar.domNode.classList.add('quick-input-tree-entry-action-bar');
7971
return {
@@ -82,12 +74,11 @@ export class QuickInputTreeRenderer<T extends IQuickTreeItem> extends Disposable
8274
checkbox,
8375
icon,
8476
label,
85-
detail,
8677
actionBar,
8778
toDisposeElement: new DisposableStore(),
8879
};
8980
}
90-
renderElement(node: ITreeNode<T, IQuickTreeFilterData>, index: number, templateData: IQuickTreeTemplateData, details?: ITreeElementRenderDetails): void {
81+
renderElement(node: ITreeNode<T, IQuickTreeFilterData>, index: number, templateData: IQuickTreeTemplateData, _details?: ITreeElementRenderDetails): void {
9182
const store = templateData.toDisposeElement;
9283
const quickTreeItem = node.element;
9384

@@ -110,7 +101,7 @@ export class QuickInputTreeRenderer<T extends IQuickTreeItem> extends Disposable
110101
templateData.icon.className = quickTreeItem.iconClass ? `quick-input-tree-icon ${quickTreeItem.iconClass}` : '';
111102
}
112103

113-
const { labelHighlights: matches, descriptionHighlights: descriptionMatches, detailHighlights } = node.filterData || {};
104+
const { labelHighlights: matches, descriptionHighlights: descriptionMatches } = node.filterData || {};
114105

115106
// Label and Description
116107
let descriptionTitle: IManagedHoverTooltipMarkdownString | undefined;
@@ -138,29 +129,6 @@ export class QuickInputTreeRenderer<T extends IQuickTreeItem> extends Disposable
138129
}
139130
);
140131

141-
// Detail
142-
if (!quickTreeItem.detail) {
143-
templateData.detail.element.style.display = 'none';
144-
} else {
145-
// If we have a tooltip, we want that to be shown and not any other hover
146-
const title = {
147-
markdown: {
148-
value: escape(quickTreeItem.detail),
149-
supportThemeIcons: true
150-
},
151-
markdownNotSupportedFallback: quickTreeItem.detail
152-
};
153-
templateData.detail.setLabel(
154-
quickTreeItem.detail,
155-
undefined,
156-
{
157-
matches: detailHighlights,
158-
title,
159-
labelEscapeNewLines: true
160-
}
161-
);
162-
}
163-
164132
// Action Bar
165133
const buttons = quickTreeItem.buttons;
166134
if (buttons && buttons.length) {

src/vs/platform/quickinput/browser/tree/quickTree.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export class QuickTree<T extends IQuickTreeItem> extends QuickInput implements I
2121
private readonly _ariaLabel = observableValue<string | undefined>('ariaLabel', undefined);
2222
private readonly _placeholder = observableValue<string | undefined>('placeholder', undefined);
2323
private readonly _matchOnDescription = observableValue('matchOnDescription', false);
24-
private readonly _matchOnDetail = observableValue('matchOnDetail', false);
2524
private readonly _matchOnLabel = observableValue('matchOnLabel', true);
2625
private readonly _activeItems = observableValue<readonly T[]>('activeItems', []);
2726
private readonly _itemTree = observableValue<ReadonlyArray<T>>('itemTree', []);
@@ -53,9 +52,6 @@ export class QuickTree<T extends IQuickTreeItem> extends QuickInput implements I
5352
get matchOnDescription(): boolean { return this._matchOnDescription.get(); }
5453
set matchOnDescription(matchOnDescription: boolean) { this._matchOnDescription.set(matchOnDescription, undefined); }
5554

56-
get matchOnDetail(): boolean { return this._matchOnDetail.get(); }
57-
set matchOnDetail(matchOnDetail: boolean) { this._matchOnDetail.set(matchOnDetail, undefined); }
58-
5955
get matchOnLabel(): boolean { return this._matchOnLabel.get(); }
6056
set matchOnLabel(matchOnLabel: boolean) { this._matchOnLabel.set(matchOnLabel, undefined); }
6157

@@ -199,8 +195,7 @@ export class QuickTree<T extends IQuickTreeItem> extends QuickInput implements I
199195
this.registerVisibleAutorun((reader) => {
200196
const matchOnLabel = this._matchOnLabel.read(reader);
201197
const matchOnDescription = this._matchOnDescription.read(reader);
202-
const matchOnDetail = this._matchOnDetail.read(reader);
203-
this.ui.tree.updateFilterOptions({ matchOnLabel, matchOnDescription, matchOnDetail });
198+
this.ui.tree.updateFilterOptions({ matchOnLabel, matchOnDescription });
204199
});
205200
this.registerVisibleAutorun((reader) => {
206201
const itemTree = this._itemTree.read(reader);

src/vs/platform/quickinput/common/quickInput.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ import Severity from '../../../base/common/severity.js';
1616
import { URI } from '../../../base/common/uri.js';
1717
import { IMarkdownString } from '../../../base/common/htmlContent.js';
1818

19-
export interface IQuickPickItemHighlights {
19+
export interface IQuickItemHighlights {
2020
label?: IMatch[];
2121
description?: IMatch[];
22+
}
23+
24+
export interface IQuickPickItemHighlights extends IQuickItemHighlights {
2225
detail?: IMatch[];
2326
}
2427

@@ -32,10 +35,6 @@ export interface IQuickItem {
3235
label: string;
3336
ariaLabel?: string;
3437
description?: string;
35-
/**
36-
* The detail text of the quick pick item. Shown as the second line.
37-
*/
38-
detail?: string;
3938
/**
4039
* Whether the item is displayed in italics.
4140
*/
@@ -47,7 +46,7 @@ export interface IQuickItem {
4746
iconClasses?: readonly string[];
4847
iconPath?: { dark: URI; light?: URI };
4948
iconClass?: string;
50-
highlights?: IQuickPickItemHighlights;
49+
highlights?: IQuickItemHighlights;
5150
buttons?: readonly IQuickInputButton[];
5251
/**
5352
* Used when we're in multi-select mode. Renders a disabled checkbox.
@@ -63,10 +62,15 @@ export interface IQuickPickItem extends IQuickItem {
6362
* The type of the quick pick item. Used to distinguish between 'item' and 'separator'
6463
*/
6564
type?: 'item';
65+
/**
66+
* The detail text of the quick pick item. Shown as the second line.
67+
*/
68+
detail?: string;
6669
/**
6770
* The tooltip for the quick pick item.
6871
*/
6972
tooltip?: string | IMarkdownString;
73+
highlights?: IQuickPickItemHighlights;
7074
/**
7175
* Allows to show a keybinding next to the item to indicate
7276
* how the item can be triggered outside of the picker using
@@ -1035,11 +1039,6 @@ export interface IQuickTree<T extends IQuickTreeItem> extends IQuickInput {
10351039
*/
10361040
matchOnDescription: boolean;
10371041

1038-
/**
1039-
* Whether to match on the detail of the items.
1040-
*/
1041-
matchOnDetail: boolean;
1042-
10431042
/**
10441043
* Whether to match on the label of the items.
10451044
*/
@@ -1154,11 +1153,6 @@ export interface IQuickTreeItem extends IQuickItem {
11541153
*/
11551154
checked?: boolean | 'partial';
11561155

1157-
/**
1158-
* TODO: Bring this back
1159-
*/
1160-
detail?: undefined;
1161-
11621156
/**
11631157
* The collapsible state of the tree item. Defaults to 'Expanded' if children are present.
11641158
*/

0 commit comments

Comments
 (0)