Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuickPick ignores matchOnDescription/matchOnDetail being false #241630

Closed
JWaters02 opened this issue Feb 23, 2025 · 5 comments
Closed

QuickPick ignores matchOnDescription/matchOnDetail being false #241630

JWaters02 opened this issue Feb 23, 2025 · 5 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@JWaters02
Copy link

Description

In the vscode extension I am working on, I have a quick pick like so:

Image

When I type a string, it tries to filter the checked items by the string, as if it is searching. However, in my code, I have

quickPick.matchOnDescription = false;
quickPick.matchOnDetail = false;

which shouldn't be needed anyway as they are false by default, but I thought I'd try this for the benefit of the doubt.

So the quick pick is ignoring the matches being false. Which is incredibly frustrating.

Here is the code I have to create the quick pick:

        const quickPick = vscode.window.createQuickPick();
        quickPick.placeholder = vscode.l10n.t("Enter the text to search for.");
        quickPick.items = [
            {
                label: vscode.l10n.t("Use Regex"),
                description: vscode.l10n.t("Should your search string be considered a regular expression?"),
                picked: false,
                iconPath: new vscode.ThemeIcon("regex"),
            },
            {
                label: vscode.l10n.t("Case Sensitive"),
                description: vscode.l10n.t("Should your search be case sensitive?"),
                picked: true,
                iconPath: new vscode.ThemeIcon("case-sensitive"),
            },
        ];
        quickPick.canSelectMany = true;
        quickPick.ignoreFocusOut = true;
        quickPick.matchOnDescription = false;
        quickPick.matchOnDetail = false;

        quickPick.show();

        quickPick.onDidAccept(async () => {
            const searchString = quickPick.value;
            if (!searchString) {
                quickPick.dispose();
                return;
            }

            const options = quickPick.selectedItems;
            const regex = options.some((option) => option.label === "Use Regex");
            const caseSensitive = options.some((option) => option.label === "Case Sensitive");

            quickPick.dispose();

            // do some stuff on the selected items here
        });
Extension.Development.Host.settings.json.-.Visual.Studio.Code.2025-02-23.14-41-55.mp4

Steps to Reproduce:

  1. Create multi-select quick pick
  2. Type in string, see that it is trying to filter on the items

Extra info

Possibly related to #226469

Does this issue occur when all extensions are disabled?: N/A - happens on extension development

Version: 1.97.2 (user setup)
Commit: e54c774
Date: 2025-02-12T23:20:35.343Z
Electron: 32.2.7
ElectronBuildId: 10982180
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.19045

@JWaters02
Copy link
Author

JWaters02 commented Feb 23, 2025

Also, there is another bug that is likely related (and I don't know if should be seperate bug report), that in my quickpick, I have one of the items as picked: true (as you can see in the code above), but when the quickpick shows, the item is not actually picked/ticked already (as you can see in the demo video).

@gjsjohnmurray
Copy link
Contributor

Also, there is another bug that is likely related

See the documentation on picked

Optional flag indicating if this item is picked initially. This is only honored when using the showQuickPick() API. To do the same thing with the createQuickPick() API, simply set the QuickPick.selectedItems to the items you want picked initially. (Note: This is only honored when the picker allows multiple selections.)

@TylerLeonhardt
Copy link
Member

quickPick.matchOnDescription = false;
quickPick.matchOnDetail = false;

Just means that the description & detail will not be considered when determining a match. In other words, when we determine if an item should show up, we will not search the description/detail for a match of the query.

If they are true, then the description/detail will be searched in addition to the label.

From your gif, this appears to be working as intended.

@TylerLeonhardt
Copy link
Member

If you are trying to show items when nothing matches, maybe you can play around with the alwaysShow property:

https://code.visualstudio.com/api/references/vscode-api#QuickPickItem

@TylerLeonhardt TylerLeonhardt added the info-needed Issue requires more information from poster label Feb 23, 2025
@JWaters02
Copy link
Author

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants