Skip to content

Commit 1994749

Browse files
authored
Add matchOnDetail and matchOnDescription to all quick picks (#4306)
1 parent 97a042d commit 1994749

File tree

7 files changed

+37
-17
lines changed

7 files changed

+37
-17
lines changed

extension/src/experiments/model/quickPick.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ describe('pickExperimentsToPlot', () => {
8383
}
8484
],
8585
MAX_SELECTED_EXPERIMENTS,
86-
Title.SELECT_EXPERIMENTS_TO_PLOT,
87-
{ matchOnDescription: true, matchOnDetail: true }
86+
{ title: Title.SELECT_EXPERIMENTS_TO_PLOT }
8887
)
8988
})
9089

@@ -192,8 +191,7 @@ describe('pickExperimentsToPlot', () => {
192191
],
193192
[],
194193
MAX_SELECTED_EXPERIMENTS,
195-
Title.SELECT_EXPERIMENTS_TO_PLOT,
196-
{ matchOnDescription: true, matchOnDetail: true }
194+
{ title: Title.SELECT_EXPERIMENTS_TO_PLOT }
197195
)
198196
})
199197
})

extension/src/experiments/model/quickPick.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ export const pickExperimentsToPlot = (
8484
items,
8585
selectedItems,
8686
MAX_SELECTED_EXPERIMENTS,
87-
Title.SELECT_EXPERIMENTS_TO_PLOT,
88-
{ matchOnDescription: true, matchOnDetail: true }
87+
{ title: Title.SELECT_EXPERIMENTS_TO_PLOT }
8988
)
9089
}
9190

extension/src/test/suite/experiments/index.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,12 @@ suite('Experiments Test Suite', () => {
10011001
picked: column.selected,
10021002
value: column
10031003
})),
1004-
{ canPickMany: true, title: Title.SELECT_COLUMNS }
1004+
{
1005+
canPickMany: true,
1006+
matchOnDescription: true,
1007+
matchOnDetail: true,
1008+
title: Title.SELECT_COLUMNS
1009+
}
10051010
)
10061011

10071012
await tableChangePromise

extension/src/test/suite/experiments/model/filterBy/tree.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,12 @@ suite('Experiments Filter By Tree Test Suite', () => {
193193
})
194194
}
195195
],
196-
{ canPickMany: true, title: Title.SELECT_FILTERS_TO_REMOVE }
196+
{
197+
canPickMany: true,
198+
matchOnDescription: true,
199+
matchOnDetail: true,
200+
title: Title.SELECT_FILTERS_TO_REMOVE
201+
}
197202
)
198203

199204
mockShowInputBox.resetHistory()

extension/src/test/suite/vscode/quickPick.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ suite('Quick Pick Test Suite', () => {
8989
items,
9090
items.slice(0, maxSelectedItems),
9191
maxSelectedItems,
92-
'select up to 3 values' as Title
92+
{ title: 'select up to 3 values' as Title }
9393
)
9494

9595
expect(
@@ -130,7 +130,7 @@ suite('Quick Pick Test Suite', () => {
130130
items,
131131
items.slice(0, maxSelectedItems - 1),
132132
maxSelectedItems,
133-
'select up to 5 values' as Title
133+
{ title: 'select up to 5 values' as Title }
134134
)
135135

136136
expect(

extension/src/vscode/quickPick.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ describe('quickPickValue', () => {
5555
const probablyC = await quickPickValue(items, { placeHolder, title })
5656
expect(mockedShowQuickPick).toHaveBeenCalledWith(items, {
5757
canPickMany: false,
58+
matchOnDescription: true,
59+
matchOnDetail: true,
5860
placeHolder,
5961
title
6062
})
@@ -93,6 +95,8 @@ describe('quickPickManyValues', () => {
9395
const result = await quickPickManyValues(items, { placeHolder, title })
9496
expect(mockedShowQuickPick).toHaveBeenCalledWith(items, {
9597
canPickMany: true,
98+
matchOnDescription: true,
99+
matchOnDetail: true,
96100
placeHolder,
97101
title
98102
})
@@ -109,6 +113,8 @@ describe('quickPickOne', () => {
109113

110114
expect(mockedShowQuickPick).toHaveBeenCalledWith(['a', 'b', 'c'], {
111115
canPickMany: false,
116+
matchOnDescription: true,
117+
matchOnDetail: true,
112118
title
113119
})
114120
expect(noResponse).toStrictEqual(undefined)
@@ -140,6 +146,8 @@ describe('quickPickYesOrNo', () => {
140146
],
141147
{
142148
canPickMany: false,
149+
matchOnDescription: true,
150+
matchOnDetail: true,
143151
placeHolder,
144152
title
145153
}

extension/src/vscode/quickPick.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { QuickPickOptions, QuickPickItem, window, QuickPick } from 'vscode'
22
import { Response } from './response'
33
import { Title } from './title'
44

5+
const DEFAULT_OPTIONS = { matchOnDescription: true, matchOnDetail: true }
6+
57
export interface QuickPickItemWithValue<T = string> extends QuickPickItem {
68
value: T
79
}
@@ -16,6 +18,7 @@ export const quickPickValue: <T = string>(
1618
) => Thenable<T | undefined> = async (items, options) => {
1719
const result = await window.showQuickPick(items, {
1820
canPickMany: false,
21+
...DEFAULT_OPTIONS,
1922
...options
2023
})
2124
return result?.value
@@ -26,6 +29,7 @@ export const quickPickManyValues: <T = string>(
2629
options: Omit<QuickPickOptionsWithTitle, 'canPickMany'>
2730
) => Thenable<T[] | undefined> = async (items, options = {}) => {
2831
const result = await window.showQuickPick(items, {
32+
...DEFAULT_OPTIONS,
2933
...options,
3034
canPickMany: true
3135
})
@@ -38,6 +42,7 @@ export const quickPickOne = (
3842
title: string
3943
): Thenable<string | undefined> =>
4044
window.showQuickPick(items, {
45+
...DEFAULT_OPTIONS,
4146
canPickMany: false,
4247
title
4348
})
@@ -49,17 +54,17 @@ const createQuickPick = <T>(
4954
canSelectMany: boolean
5055
placeholder?: string
5156
title: Title
52-
matchOnDescription?: boolean
53-
matchOnDetail?: boolean
57+
matchOnDescription: boolean
58+
matchOnDetail: boolean
5459
}
5560
): QuickPick<QuickPickItemWithValue<T>> => {
5661
const quickPick = window.createQuickPick<QuickPickItemWithValue<T>>()
5762

5863
quickPick.canSelectMany = options.canSelectMany
5964
quickPick.placeholder = options.placeholder
6065
quickPick.title = options.title
61-
quickPick.matchOnDescription = options.matchOnDescription || false
62-
quickPick.matchOnDetail = options.matchOnDetail || false
66+
quickPick.matchOnDescription = options.matchOnDescription
67+
quickPick.matchOnDetail = options.matchOnDetail
6368

6469
quickPick.items = items
6570
if (selectedItems) {
@@ -75,6 +80,7 @@ export const quickPickOneOrInput = (
7580
new Promise(resolve => {
7681
const quickPick = createQuickPick<string>(items, undefined, {
7782
canSelectMany: false,
83+
...DEFAULT_OPTIONS,
7884
...options
7985
})
8086

@@ -189,13 +195,12 @@ export const quickPickLimitedValues = <T>(
189195
items: QuickPickItemWithValue<T>[],
190196
selectedItems: readonly QuickPickItemWithValue<T>[],
191197
maxSelectedItems: number,
192-
title: Title,
193-
options?: { matchOnDescription?: boolean; matchOnDetail?: boolean }
198+
options: QuickPickOptions & { title: Title }
194199
): Promise<Exclude<T, undefined>[] | undefined> =>
195200
new Promise(resolve => {
196201
const quickPick = createQuickPick(items, selectedItems, {
202+
...DEFAULT_OPTIONS,
197203
canSelectMany: true,
198-
title,
199204
...options
200205
})
201206

0 commit comments

Comments
 (0)