Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement glob match for path and extension search in Locate bar #336

Closed
Curculigo opened this issue Sep 24, 2024 · 17 comments
Closed

Implement glob match for path and extension search in Locate bar #336

Curculigo opened this issue Sep 24, 2024 · 17 comments
Assignees
Labels
enhancement New feature or request ready for release

Comments

@Curculigo
Copy link

Curculigo commented Sep 24, 2024

I want to list all files that have .txt extension in an opened folder.

@SpartanJ
Copy link
Owner

How? All at once? How would you do it in other editor?
If you just want to search for a file use the universal locator... CTRL+K or Alt+1.

@Curculigo
Copy link
Author

Curculigo commented Sep 24, 2024

Sorry. I mean listing them, not opening them all at once. I will choose which ones to open in the list.

@SpartanJ
Copy link
Owner

Go To Locate (Ctrl+k or Alt+1 or click in "Locate" below -> write: .txt. It should be enough.

@Curculigo
Copy link
Author

Curculigo commented Sep 24, 2024

Will it do a search recursively in all sub-directories of the opened folder?

@SpartanJ
Copy link
Owner

Yes, exactly. When you open a folder it generates the complete list of files from the extensions supported and you can find any file from the locator.

@Curculigo
Copy link
Author

Can I tell it to search only in a specific sub-directory? I don't want to open that directory as the new folder.

@SpartanJ
Copy link
Owner

You can filter from path, so if you need to search some sub-directory you write the partial path: root/subdir/etc and it will list files from there.

@Curculigo
Copy link
Author

Will something like root/subdir/etc/.txt work?

@SpartanJ
Copy link
Owner

Yes, it's a fuzzy search, it will try to approximate the result:
Screenshot_20240924_171229

@Curculigo
Copy link
Author

Curculigo commented Sep 24, 2024

I don't think the feature works as intended. Do you still have llvm-mingw? Try opening llvm-mingw-20240917-ucrt-x86_64 as a folder and listing all header files (.h extension) in the include directory. The list is definitely not complete.

@Curculigo
Copy link
Author

I found another quirk. Try to list all files in the bin directory with bin\. It will not list all files in bin as intended and will also list files not in bin, e.g: files in lib. Btw, I think forward slash should be used instead of backward slash. I tried with forward slash (bin/) and it doesn't work.

@SpartanJ
Copy link
Owner

I don't think you understood how the feature works, it's a fuzzy search, given low density information like .h won't give you good results, it's not trying to filter directories or files, it's just doing a quick string matching, some improvements can be done to have better approximations for your use case: for example, I could give more weight to recognized extensions if written, or try to prioritize filtering folders if a folder separator is used (/ or \). Fuzzy search is more oriented to do file search than what you're trying to achieve, it's a very common feature in modern editors. I'll change the feature request title to "improve fuzzy search for path and extension matching".

@SpartanJ SpartanJ changed the title Search for files in an opened folder Improve fuzzy search for path and extension matching Sep 24, 2024
@SpartanJ SpartanJ self-assigned this Sep 24, 2024
@SpartanJ SpartanJ added the enhancement New feature or request label Sep 24, 2024
@Curculigo
Copy link
Author

This is the first time I hear about fuzzy search. Is it the same thing as the search suggestions in the address bar of Firefox? It will suggest to you the URLs in history or bookmarks based on what you have typed.

@SpartanJ
Copy link
Owner

I'm simply using this feature wrong. There is no enhancement needed.

Understood, but I do think it's a good idea to have a mode where filtering works the way you're looking for, I'm thinking I can add and extra mode as these ones and filter with a glob pattern match.

This is the first time I hear about fuzzy search. Is it the same thing as the search suggestions in the address bar of Firefox? It will suggest to you the URLs in history or bookmarks based on what you have typed.

They use a fuzzy search too, probably different because they match against different kind of information but yes.

@Curculigo
Copy link
Author

I'm simply using this feature wrong. There is no enhancement needed.

Understood, but I do think it's a good idea to have a mode where filtering works the way you're looking for, I'm thinking I can add and extra mode as these ones and filter with a glob pattern match.

I found more quirks of the feature. This is the reason why I deleted my previous comments. It's really weird. For example, it can't provide suggestions for the x86_64-w64-mingw32 directory. I typed x86 and it suggested some header files whose names started with x86 to me. But immediately after I typed _, it started to suggest nonsense. Why can't it handle x86_ correctly?

@SpartanJ
Copy link
Owner

It's just a probabilistic algorithm, it will assign some score based on the consequent matches found in a string and sort the list by score. If it was nonsense to you it's probably because there are no good matches with _. The idea is that approximate a result based on what the user wrote even if it's not exactly that. It's a veeery simple algorithm, it can be improved, there are many fuzzy match implementations.

@SpartanJ SpartanJ changed the title Improve fuzzy search for path and extension matching Implement glob match for path and extension search in Locate bar Sep 25, 2024
@SpartanJ
Copy link
Owner

I ended up implementing it for me, it can be useful having the possibility of glob matching the directory tree:

2024-09-24.23-15-15.noaudio.mp4

@SpartanJ SpartanJ closed this as completed Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready for release
Projects
None yet
Development

No branches or pull requests

2 participants