Skip to content

Have createQuickPick no longer sort by label #73904

Open

Description

@pelmers

Similar to #63050, I wish to avoid the final sort on the quick pick list. I am using the quickpick as a search field, and the items field I set is already sorted by my relevance metric, so I do not want to have VS Code sort the list again . Specifically, I want an option to skip this block:

if (query) {
const normalizedSearchValue = query.toLowerCase();
shownElements.sort((a, b) => {
return compareEntries(a, b, normalizedSearchValue);
});
}
)

Activity

  1. added
    search
    on May 17, 2019
  2. removed
    search
    on May 19, 2019
  3. added
    feature-request
    quick-pick
    on May 20, 2019
  4. pelmers commented on Jun 24, 2019

    @pelmers
    ContributorAuthor

    I would like to implement this by adding a property sortByValue to QuickPickOptions on the extension API (true by default) to control this sorting. Does that sound reasonable and would you review such a PR? Christof Marti (@chrmarti)

  5. chrmarti commented on Jun 25, 2019

    @chrmarti
    Collaborator

    I wonder if that would be sufficient. What about the highlighting of the search term on the labels? Would you want to turn that off too?

  6. pelmers commented on Jun 25, 2019

    @pelmers
    ContributorAuthor

    Christof Marti (@chrmarti) highlighting the search term's not in the scope of this issue. Could you explain why you brought it up?

    I am concerned the sorting case in particular because this sort() call happens in the renderer itself. Since the extension API expects a list of items rather than a set or map, it seems logical to me to let the extension to decide that this list is already sorted and let the renderer save some processing time (especially for large lists).

  7. chrmarti commented on Jun 26, 2019

    @chrmarti
    Collaborator

    I don't want to add API without understanding the long-term direction and the highlighting, filtering and sorting all play into this.

    The QuickPickOptions already have matchOnDescription and matchOnDetail flags and these control filtering and highlighting.

  8. pelmers commented on Jun 26, 2019

    @pelmers
    ContributorAuthor

    Thanks for responding! I also noticed that filter/highlight can only be toggled for the description and detail fields, not the label field.

    I imagine there was some kind of discussion when the API was originally added about its long-term vision; unfortunately that was before 'Hello Code' so it isn't in public history.

    Allowing the extension to decide whether to sort results will let it provide a better experience to the user any time the default metric of 'index of first match' is not the best one.

    For another example, an extension might want to keep the list grouped by category, similar to how built-in file search quickpick groups Recently opened, Search results, and Document symbols in that order.

  9. chrmarti commented on Jun 28, 2019

    @chrmarti
    Collaborator

    We could add matchOnLabel (like we internally already did) to the API and couple that with filtering, highlighting and sorting. (Currently the sorting is only done based on the label.) That would fit nicely with the existing API while not exposing too fine-grained options that are hard to use.

  10. sergei-dyshel commented on Jun 29, 2019

    @sergei-dyshel

    After reading the discussion I still fail to understand how we went from optional sorting feature request to discussing filtering options which are not dependent on sorting in any way....

  11. chrmarti commented on Jul 1, 2019

    @chrmarti
    Collaborator

    When you want to control sorting yourself, you probably also want to control filtering. I don't want to introduce a flag specific to sorting now only to discover that doesn't solve the entire issue.

  12. 57 remaining items

  13. changed the title [-]Add option to skip sorting QuickPick items[/-] [+]Have `createQuickPick` no longer sort by label[/+] on Feb 1, 2024
  14. gjsjohnmurray commented on Feb 1, 2024

    @gjsjohnmurray
    Contributor

    TylerLeonhardt I'm trying to understand how this won't be a breaking change.

  15. TylerLeonhardt commented on Feb 2, 2024

    @TylerLeonhardt
    Member

    Right, yeah it's a change we'd like to make to get a read on how many extensions depend on the existing behavior. Our suspicion is that this existing behavior is hurting extensions more than it helps and thus the behavior of the API should change.

    Naturally, this is not an actual API breakage, since no API shape is changing... it's a behavior difference.

    There is a chance that such a change would cause issues... if so, we'll re-evaluate.

  16. simonvanbernem commented on Jun 10, 2024

    @simonvanbernem

    Hi,

    I'm new to developing for VSCode and am very interested in this API-change (to create a go-to symbol that is closer to the one from sublime text), but seeing that it got put back into the backlog after being part of milestone twice is confusing to me.

    Does that mean it won't happen in the near future? Was it decided to not implement this change after all?

  17. nickolay-kondratyev commented on Nov 13, 2025

    @nickolay-kondratyev

    Naturally, this is not an actual API breakage, since no API shape is changing... it's a behavior difference. - TylerLeonhardt

    TylerLeonhardt I'd argue this is actually an API breakage. An API encompasses not only what is exposed through interface but also the behavior that users have come to expect.

    See Hyrum's Law

    If you are going to change external facing behaviors of APIs highly consider deprecating and introducing new APIs instead of changing behavior under the customers, which can break usages in unknown ways.

  18. Luke-Callaghan23 commented on Apr 3, 2026

    @Luke-Callaghan23

    Is there any plan for this coming back around in the future? I'd be interested in seeing this change as well.

  19. calsys456 commented on Apr 24, 2026

    @calsys456

    I successfully avoided misleading sort by zipping zero-width spaces into the label, so that the QuickPickItem can never be matched and sorted, and i can sort & filter items manually myself. The only downside is that the incremental matched-highlight will missing, but i think it's not a big problem against the chaotic ordered items... Put it here for those who desperately want this feature lol

    class ManualSortItem implements vscode.QuickPickItem {
      label: string = "";
      origLabel: string = "";
      get labelText() {
        return this.origLabel;
      }
      set labelText(text: string) {
        // Listen to me you VSCode scum: you can root around all you want, but
        // you'll never match me, and you'll never sort me! You call yourself a
        // programmer?
        this.label = [...text].join("\u200B");
        this.origLabel = text;
      }
      constructor(label: string) {
        this.labelText = label;
      }
    }
  20. lppedd commented on Nov 20, 2026

    @lppedd

    Any news on the stabilization of this proposed API? This is extremely useful when custom sorting is essential to list items in the order the user expects them. It's not the first time we have complaints from users asking us "why is the last value I added here being shown last in the quick pick when I use a filter"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apiapi-proposalfeature-requestquick-pick

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions