microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.64k stars 28.69k forks source link

Sorting is not correct when looking for `Profiles: ` commands #173767

Open sandy081 opened 1 year ago

sandy081 commented 1 year ago
image
bpasero commented 4 months ago

Whats the issue here?

sandy081 commented 4 months ago

Developer: Reset... and Preferences: Open... commands are shown before Profiles:... commands

bpasero commented 4 months ago

Yes, this is somewhat intentional for commands: we have always sorted matching commands by alphabet to try to group related entries together that share the same prefix and keep the order predictable. We have intentionally not added fuzzy search ranking to commands.

TylerLeonhardt commented 3 months ago

People have been hitting this issue more, recently. I wonder why... could be more commands in the command palette making finding the right command at the top challenging?

isidorn commented 3 months ago

@bpasero this does not look related to fuzzy matching. But shorter titles should get some boost. For example: if my command title has 50 characters and 5 are matching. It should be ranked below a title with 20 characters where 5 are matching.

bpasero commented 3 months ago

I cannot find the issue anymore where I explained our reasoning in greater detail, let me post here again: the sorting in the commands picker is historic and we had reasons to do it back then, which I am happy to revisit today if we all agree.

For the longest time, commands picker did not have a list of "most recently used commands" and it was very frustrating to find the right command, given the alphabetic sorting. I added commands history as a way to mitigate that: the history will put results to the top in their order of usage if matching the search query.

image

With the idea being that you can build muscle memory very quickly that a query such as "copy" will very likely put the one command to the top that you had always used.

Now, if you leave the history beside and just look at the commands sorting, as you know commands appear in alphabetic order if they match the search input. There is no boost, no fuzzy match, just simple sorting by alphabet. The reason here was to try to keep command results predictable: the order will not change based on your input and similar commands are always appearing together in the same order.

If we make changes here, I would suggest to run them behind an experiment with a setting to toggle and measure how people react. I am not sure I would change sorting in the "recently used" bucket to reduce chance of breaking muscle memory.

isidorn commented 1 month ago

This is getting more important now. Consider this flow:

https://github.com/user-attachments/assets/d3b18806-3cd6-40f4-86e0-fa0c6a206b0a

Thus, Copilot is sending more "exact matches" to the command palette. And imagine a new user coming to this. We need to make sure that the 100% match is the first result.

bpasero commented 1 month ago

If chat knows exactly the command to use, an alternative would be to open command palette with the ID of the command. In that case we only show the matching command.

isidorn commented 1 month ago

Well it is AI driven from @vscode, so I am not sure if it can always provide a command ID to use @bhavyaus I would still prefer to "fix" the sorting.

bhavyaus commented 1 month ago

@bpasero @vscode does have the original cmd ID, but setting up the quick pick to open with the cmd id results in this: Image

We're using the workbench.action.quickOpen cmd with the label as the argument. So, we use the exact cmd label instead. Revisiting the sorting would be a better fix here.

bpasero commented 1 month ago

I leave it up to Tyler, who owns this. A pragmatic solution would be to force a command to the top when it literally matches the words you typed entirely.

TylerLeonhardt commented 1 month ago

@bhavyaus whats the problem with your screenshot? The command you want is at the top, no?

hediet commented 4 weeks ago

In this case, the sorting is so bad, I'd see it as a bug:

Image

If multiple words match, the rank should be the sum of the indexes of all matching words, multiplied by some factor (first index by 1, second index by 2, third by 3 and so on). Then the results should be sorted ascending by that rank.

bhavyaus commented 3 weeks ago

@bhavyaus whats the problem with your screenshot? The command you want is at the top, no?

My screenshot was to show why searching via command id when opening the command palette from @vscode responses is not the best approach to teaching users about a command. Ideally the sort order would be fixed so that searching via keywords would surface the right commands.