microsoft / vscode

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

Enable fuzzy matching for picker #34088

Open ramya-rao-a opened 7 years ago

ramya-rao-a commented 7 years ago

Have a quick pick control with these values ["hello", "hello_there"]

Type ht or hello_ -> hello_there will show up Type he_ -> no results

bpasero commented 7 years ago

@ramya-rao-a I looked into this and this is because true fuzzy matching is not enabled for the picker. The difference to our current matching strategy is that true fuzzy matching allows to return a result as matching if the search characters are part of the target word even if there are other characters in between. The fact that ht matches is due to our camel case matching.

I think it would be tough to enable this for all pickers so we might need an option here for the extension to enable this.

szyhf commented 7 years ago

Nice ~

fabiospampinato commented 6 years ago

@bpasero why are there even different algorithms being used? This is surprising to me.

We surely can't expect users to think "is fuzzy search enabled in this picker? maybe I should search for bar instead of br here". If there was an option for extensions to enable fuzzy search this kind of reasoning would become even messier.

I think it would be tough to enable this for all pickers

Why is that?

bpasero commented 6 years ago

@fabiospampinato the fuzzy scoring we do currently was tweaked for file names only, it is not a general purpose fuzzy scorer. That is why it was not enabled for all contexts. I think before we can do that we should revisit our current implementation and think about dropping in a better one that is just generally matching better.

fabiospampinato commented 6 years ago

@bpasero I think the "filtering" and "ranking" logic should be considered separately. It would be pretty easy to enable fuzzy filtering everywhere (ranking results naively on the order of appearance) while still having a custom ranking logic for file paths.

Eskibear commented 6 years ago

@bpasero I cannot figure out why here 1 matchs but 2 not ?

image

More details here: https://github.com/Microsoft/vscode-spring-initializr/issues/26#issuecomment-359306866

Version 1.19.1
Commit 0759f77bb8d86658bc935a10a64f6182c5a1eeba
Date 2017-12-19T09:46:02.926Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture ia32
bpasero commented 6 years ago

@Eskibear we have a heuristic when we should try to match on camel casing (by jumping over words), but this heuristic is limited to entries < 60 characters length for performance reasons. The second label simply seems too long for that kind of matching to apply.

smbkr commented 4 years ago

I think it would be tough to enable this for all pickers so we might need an option here for the extension to enable this.

@bpasero it's been more than a couple of years since this was looked at. Has anything changed in the current state of VSCode that would make it easier to implement fuzzy search everywhere? This limitation has come up a number of times in extensions as can be seen from the mentions.

xh3b4sd commented 3 years ago

I created https://github.com/alefragnani/vscode-project-manager/issues/428 and was directed to here. It looks like there are quite a couple of supporting arguments to improve the current state of searching. Though what I am not sure about is why the behaviour in search is different when searching for different things.

gpeal commented 1 year ago

I recently switched from the IntelliJ world to VSCode and the fuzzy match algorithm of VSCode is slowly driving me insane. In addition to the cases here, one thing that IntelliJ gets really right is case sensitive matching of partial words and priority for local symbols.

Check out this example. I am trying to match externalReport which is defined on the line immediately above. ext correctly matches. Typing R should increase the weight of the already-top result but instead, it drops off the list entirely.

The result of this is that I frequently wind up with random variables and imports as a result of the correct result disappearing after I type more letters that should only increase its weight.

CleanShot 2022-12-02 at 16 52 34@2x (1) CleanShot 2022-12-02 at 16 52 30@2x (1)

You can see a similar result play out here: CleanShot 2022-11-30 at 13 44 37@2x (1) vs WebStorm:

CleanShot 2022-11-30 at 13 45 20@2x (1)
gpeal commented 1 year ago

Here's another example. I think it is reasonable to expect InteractiveTableComponent to be matched above footprintTaggingBuilderAddRuleComponent, right?

CleanShot 2023-05-31 at 17 23 34@2x