From 5e97e92d825b83c8eda0a15965f0470b2d28b688 Mon Sep 17 00:00:00 2001 From: Matt Seddon Date: Wed, 19 Jul 2023 13:18:59 +1000 Subject: [PATCH] Add matchOnDetail and matchOnDescription to all quick picks --- .../src/experiments/model/quickPick.test.ts | 6 ++---- extension/src/experiments/model/quickPick.ts | 3 +-- .../src/test/suite/experiments/index.test.ts | 7 ++++++- .../experiments/model/filterBy/tree.test.ts | 7 ++++++- .../src/test/suite/vscode/quickPick.test.ts | 4 ++-- extension/src/vscode/quickPick.test.ts | 8 ++++++++ extension/src/vscode/quickPick.ts | 19 ++++++++++++------- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/extension/src/experiments/model/quickPick.test.ts b/extension/src/experiments/model/quickPick.test.ts index e4691e6529..93b8bac230 100644 --- a/extension/src/experiments/model/quickPick.test.ts +++ b/extension/src/experiments/model/quickPick.test.ts @@ -83,8 +83,7 @@ describe('pickExperimentsToPlot', () => { } ], MAX_SELECTED_EXPERIMENTS, - Title.SELECT_EXPERIMENTS_TO_PLOT, - { matchOnDescription: true, matchOnDetail: true } + { title: Title.SELECT_EXPERIMENTS_TO_PLOT } ) }) @@ -192,8 +191,7 @@ describe('pickExperimentsToPlot', () => { ], [], MAX_SELECTED_EXPERIMENTS, - Title.SELECT_EXPERIMENTS_TO_PLOT, - { matchOnDescription: true, matchOnDetail: true } + { title: Title.SELECT_EXPERIMENTS_TO_PLOT } ) }) }) diff --git a/extension/src/experiments/model/quickPick.ts b/extension/src/experiments/model/quickPick.ts index 582ba1cb63..dfae52b9a0 100644 --- a/extension/src/experiments/model/quickPick.ts +++ b/extension/src/experiments/model/quickPick.ts @@ -84,8 +84,7 @@ export const pickExperimentsToPlot = ( items, selectedItems, MAX_SELECTED_EXPERIMENTS, - Title.SELECT_EXPERIMENTS_TO_PLOT, - { matchOnDescription: true, matchOnDetail: true } + { title: Title.SELECT_EXPERIMENTS_TO_PLOT } ) } diff --git a/extension/src/test/suite/experiments/index.test.ts b/extension/src/test/suite/experiments/index.test.ts index 2dab7fcf0c..96e95ea578 100644 --- a/extension/src/test/suite/experiments/index.test.ts +++ b/extension/src/test/suite/experiments/index.test.ts @@ -1000,7 +1000,12 @@ suite('Experiments Test Suite', () => { picked: column.selected, value: column })), - { canPickMany: true, title: Title.SELECT_COLUMNS } + { + canPickMany: true, + matchOnDescription: true, + matchOnDetail: true, + title: Title.SELECT_COLUMNS + } ) await tableChangePromise diff --git a/extension/src/test/suite/experiments/model/filterBy/tree.test.ts b/extension/src/test/suite/experiments/model/filterBy/tree.test.ts index 7a0f26ddb6..2168f73d6c 100644 --- a/extension/src/test/suite/experiments/model/filterBy/tree.test.ts +++ b/extension/src/test/suite/experiments/model/filterBy/tree.test.ts @@ -193,7 +193,12 @@ suite('Experiments Filter By Tree Test Suite', () => { }) } ], - { canPickMany: true, title: Title.SELECT_FILTERS_TO_REMOVE } + { + canPickMany: true, + matchOnDescription: true, + matchOnDetail: true, + title: Title.SELECT_FILTERS_TO_REMOVE + } ) mockShowInputBox.resetHistory() diff --git a/extension/src/test/suite/vscode/quickPick.test.ts b/extension/src/test/suite/vscode/quickPick.test.ts index 47a05c9c18..08d43541dd 100644 --- a/extension/src/test/suite/vscode/quickPick.test.ts +++ b/extension/src/test/suite/vscode/quickPick.test.ts @@ -89,7 +89,7 @@ suite('Quick Pick Test Suite', () => { items, items.slice(0, maxSelectedItems), maxSelectedItems, - 'select up to 3 values' as Title + { title: 'select up to 3 values' as Title } ) expect( @@ -130,7 +130,7 @@ suite('Quick Pick Test Suite', () => { items, items.slice(0, maxSelectedItems - 1), maxSelectedItems, - 'select up to 5 values' as Title + { title: 'select up to 5 values' as Title } ) expect( diff --git a/extension/src/vscode/quickPick.test.ts b/extension/src/vscode/quickPick.test.ts index ee6a436bd0..742de96602 100644 --- a/extension/src/vscode/quickPick.test.ts +++ b/extension/src/vscode/quickPick.test.ts @@ -55,6 +55,8 @@ describe('quickPickValue', () => { const probablyC = await quickPickValue(items, { placeHolder, title }) expect(mockedShowQuickPick).toHaveBeenCalledWith(items, { canPickMany: false, + matchOnDescription: true, + matchOnDetail: true, placeHolder, title }) @@ -93,6 +95,8 @@ describe('quickPickManyValues', () => { const result = await quickPickManyValues(items, { placeHolder, title }) expect(mockedShowQuickPick).toHaveBeenCalledWith(items, { canPickMany: true, + matchOnDescription: true, + matchOnDetail: true, placeHolder, title }) @@ -109,6 +113,8 @@ describe('quickPickOne', () => { expect(mockedShowQuickPick).toHaveBeenCalledWith(['a', 'b', 'c'], { canPickMany: false, + matchOnDescription: true, + matchOnDetail: true, title }) expect(noResponse).toStrictEqual(undefined) @@ -140,6 +146,8 @@ describe('quickPickYesOrNo', () => { ], { canPickMany: false, + matchOnDescription: true, + matchOnDetail: true, placeHolder, title } diff --git a/extension/src/vscode/quickPick.ts b/extension/src/vscode/quickPick.ts index ed3d54d523..430d5fd739 100644 --- a/extension/src/vscode/quickPick.ts +++ b/extension/src/vscode/quickPick.ts @@ -2,6 +2,8 @@ import { QuickPickOptions, QuickPickItem, window, QuickPick } from 'vscode' import { Response } from './response' import { Title } from './title' +const DEFAULT_OPTIONS = { matchOnDescription: true, matchOnDetail: true } + export interface QuickPickItemWithValue extends QuickPickItem { value: T } @@ -16,6 +18,7 @@ export const quickPickValue: ( ) => Thenable = async (items, options) => { const result = await window.showQuickPick(items, { canPickMany: false, + ...DEFAULT_OPTIONS, ...options }) return result?.value @@ -26,6 +29,7 @@ export const quickPickManyValues: ( options: Omit ) => Thenable = async (items, options = {}) => { const result = await window.showQuickPick(items, { + ...DEFAULT_OPTIONS, ...options, canPickMany: true }) @@ -38,6 +42,7 @@ export const quickPickOne = ( title: string ): Thenable => window.showQuickPick(items, { + ...DEFAULT_OPTIONS, canPickMany: false, title }) @@ -49,8 +54,8 @@ const createQuickPick = ( canSelectMany: boolean placeholder?: string title: Title - matchOnDescription?: boolean - matchOnDetail?: boolean + matchOnDescription: boolean + matchOnDetail: boolean } ): QuickPick> => { const quickPick = window.createQuickPick>() @@ -58,8 +63,8 @@ const createQuickPick = ( quickPick.canSelectMany = options.canSelectMany quickPick.placeholder = options.placeholder quickPick.title = options.title - quickPick.matchOnDescription = options.matchOnDescription || false - quickPick.matchOnDetail = options.matchOnDetail || false + quickPick.matchOnDescription = options.matchOnDescription + quickPick.matchOnDetail = options.matchOnDetail quickPick.items = items if (selectedItems) { @@ -75,6 +80,7 @@ export const quickPickOneOrInput = ( new Promise(resolve => { const quickPick = createQuickPick(items, undefined, { canSelectMany: false, + ...DEFAULT_OPTIONS, ...options }) @@ -189,13 +195,12 @@ export const quickPickLimitedValues = ( items: QuickPickItemWithValue[], selectedItems: readonly QuickPickItemWithValue[], maxSelectedItems: number, - title: Title, - options?: { matchOnDescription?: boolean; matchOnDetail?: boolean } + options: QuickPickOptions & { title: Title } ): Promise[] | undefined> => new Promise(resolve => { const quickPick = createQuickPick(items, selectedItems, { + ...DEFAULT_OPTIONS, canSelectMany: true, - title, ...options })