Which algorithm is used to implement search for files in Visual Studio Code / Google Chrome Developer / Sublime (Ctrl+p or Cmd+p)?

This looks like the code that DevTools uses for its fuzzy search in the Command Menu.

https://cs.chromium.org/chromium/src/third_party/WebKit/Source/devtools/front_end/quick_open/CommandMenu.js?l=174

And the underlying diff algorithm is:

https://cs.chromium.org/chromium/src/third_party/WebKit/Source/devtools/front_end/diff/Diff.js?q=Diff.Diff&dr=CSs&l=4


The VS Code functionality you're looking for can be tracked by looking into what happens when this function is called:

https://github.com/microsoft/vscode/blob/master/src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts#L365

an interesting part here (filter on the first term only , then on the whole filter):

https://github.com/microsoft/vscode/blob/d1220da07267242e9b58193da0ded43bbe7f2aa5/src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts#L570

If you dig from there you will find that most of the useful stuff is regrouped in this file:

https://github.com/microsoft/vscode/blob/master/src/vs/base/common/fuzzyScorer.ts

Some notes:

The fuzzy search is pretty strict, the filter will not match if a single letter is not found or if the letters are not found in the right order. A key advantage is that you can highlight the matching part in the results and it makes pretty clear what's happening to your users.

The fuzzy scorer scores results based on a matching label/description[/path] (for a file, label = filename, description = path without name).