Skip to content

Support custom QuickPick filter logic #90521

@brunnerh

Description

@brunnerh

Currently the QuickPick filter logic supports wild cards and which parts of the item to search in but not things like switched up word order or regex. An issue was opened for one of my extensions asking for a more lenient search, which does not seem possible with the current API.

Rather than adding a lot of options specifying exactly how the filtering behaves it might be easier and more sensible to provide a custom filter callback and maybe a filter delay option. The delay would trigger the filter logic only n milliseconds after the user has last typed, in case the filter logic is complex or there are many items (- i have 33k -) causing long filter times.

Suggested interface for the options:

interface QuickPickOptions {
	// ...

	/**
	 * Time in milliseconds to wait after last user input
	 * before filtering the list.
	 * @default 0
	 */
	filterDelay: number,

	/**
	 * Optional filter callback which overrides the default filter
	 * behavior. The callback is called for every item in the list
	 * with the current user input.
	 * @default undefined
	 */
	filterCallback?: (item: QuickPickItem | string, filterText: string) => boolean,
}

I had a look at handling a quick pick "manually" by using createQuickPick but it also filters completely automatically.


Maybe QuickPickOptions could also be made generic. It already has the onDidSelectItem property which uses a union for the item type instead of a generic. Then functions like showQuickPick<T extends QuickPickItem> could propagate their generic type to the options argument.

Metadata

Metadata

Labels

feature-requestRequest for new features or functionalityquick-pickQuick-pick widget issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions