question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support custom QuickPick filter logic

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:10
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
chrmarticommented, Feb 21, 2020

Setting alwaysShow: true on the items and sortByLabel: false (#73904 proposed API) on the QuickPick allows you to control the list and sorting. Only the highlighting cannot be controlled yet, that is tracked with #83424.

Keeping this issue open as its own proposal until the issues are resolved.

4reactions
rmanthorpecommented, Aug 25, 2020

@brunnerh if we could disable matchOnLabel (see #83425) (as well asmatchOnDescription and matchOnDetail which we already have you could just disable matching and implement the filtering yourself before you put the QuickPickItems into the QuickPick. Coupled with custom highlighting (#83424) you would be able to do whatever you like.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filter Smarter with Custom Filter Logic - Salesforce Help
Define custom filter logic with parentheses and the AND, OR, and NOT Boolean operators, such as (1 AND 2) OR 3. Previously, you...
Read more >
VS Code API | Visual Studio Code Extension API
VS Code API. VS Code API is a set of JavaScript APIs that you can invoke in your Visual Studio Code extension. This...
Read more >
Define Mapping Relationships as 'For Documentation Only' - Help
... the property definitions but that the support for these mapping relationships is hard-coded (and ... Define a Filter for an Engineering Data...
Read more >
Visual Studio Code 1.71.1 Release - GitClear
Simplify code action menu building logic · #159776 · support pinning in `Run Task` quickpick ... Allow passing in custom workspace/parser to markdown...
Read more >
@theia/plugin - npm
//configure quick pick options const option: theia. ... A document symbol provider allows to add a custom logic for symbols detection.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found