@@ -2,6 +2,8 @@ import { QuickPickOptions, QuickPickItem, window, QuickPick } from 'vscode'
22import { Response } from './response'
33import { Title } from './title'
44
5+ const DEFAULT_OPTIONS = { matchOnDescription : true , matchOnDetail : true }
6+
57export 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