Open smbkr opened 5 years ago
I would love to tackle this. Let me hear if that is possible if I can work on this.
Also what do you guys prefer, implementing your own fuzzy search algorithm or using a node package like Fuse.js( https://fusejs.io/ ) for example? Would love to hear back from you @felipecaputo ,
Hi @akdir , that's great to hear it from you.
First of all, I'd like to apologize for taking to long to reply to you.
I don't think we would need to implement it again, and the library you suggested seems to be pretty solid.
You can count on me with anything to accomplish this, and I would love to see this feature on the extensions.
Hi @felipecaputo, thanks for replying back.
I just finished implementing fuzzy searching on the extension. It now works pretty good, but I still want to change some settings to make it much more sensitive.
I did use Fuse.js. I worked some hours of my night on this. And most of the time was researching how the VScode API works and understanding your extension. It was much fun and I learned quite a bit :). I will make a new pull request tomorrow. It has become too late now(02:00 AM xD).
I would like to have this request be added as a hacktoberfest request. This will be my first hacktober pull request ever, so I am very excited!
Hi @felipecaputo, I have very bad news :(.
So after almost pulling all my hairs out, I found out that it is not possible in VsCode to use fuzzy searching on QuickPick function. I used Fuse.js to seach fuzzy and it worked, that is why I wrote before that it works and that I will do a pull request tomorrow. So it does indeed filter out and searches fuzzy like you want to, but it is impossible to disable the default filter in QuickPick. You can not implement your own filter.
Until the developers of Vscode changes this, it is sadly not going to work Q_Q.
The only function that I changed was showProjectList. Here it is, if you would like to see for yourself @felipecaputo:
/**
* Show the list of found Git projects, and open the choosed project
*
* @param {Object} opts Aditional options, currently supporting only subfolders
* @param {boolean} openInNewWindow If true, will open the selected project in a new windows, regardless of the OpenInNewWindow configuration
*
* @memberOf GitProjectManager
*/
showProjectList(openInNewWindow, opts = {}) {
this.getProjectsFolders(opts)
.then(folders => this.getProjectsList(folders))
.then(items => {
var fuse = new Fuse(items, {keys:['label']})
var options = {
placeHolder: 'Select a folder to open: (it may take a few seconds to search the folders the first time)'
};
var quickPick = vscode.window.createQuickPick()
quickPick.placeholder = options.placeHolder;
quickPick.items = items;
quickPick.onDidChangeValue(text => {quickPick.items = fuse.search(text); console.log(text, quickPick.items)})
quickPick.onDidChangeSelection(selected => { selected = selected[0];
if (selected) {
this.openProject(selected, openInNewWindow);
}})
quickPick.onDidHide(() => {vscode.window.showInformationMessage(`Error while showing Project list: ${reason}`)})
quickPick.show();
})
.catch(this.handleError);
};
So, it was fun to work on it, but sadly it does not work like we want to. If the VSCode Team would add the option to use your own filter on the Pickers then this code should work immediately.
There's an open issue on the VSCode repo here: https://github.com/microsoft/vscode/issues/34088
@smbkr , Yeah I found that open issue on the VSCode after I started doing this Issue, should maybe next time check if it is possible to fix an extension issue after checking the open issues on VSCode. I hope someday the VSCode Team will fix this issue. Still thanks for showing me the issue on VSCode.
Is your feature request related to a problem? Please describe.
It's frustrating to type "my api" in the 'open project' menu and get no matches, because the repo is actually named "my_api". I'd expect it to use fuzzy matching here.
Describe the solution you'd like Use fuzzy matching algorithm when searching projects.
Describe alternatives you've considered N/A
Additional context VS Code's own file search does this. Searching for "file mapper" produces a result for "my_file_mapper.py". Searching for "es ch" produces a result for "test_cache.py"