microsoft / vscode

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

Search/sort files by custom label #214770

Open akomm opened 4 months ago

akomm commented 4 months ago

Recording visualizing current behavior when searching files with custom labels: search-custom-label.webm

Explanation: As you can see in the recording, when searching for files, vscode will only match by the real file name, not the custom label.

Additionally it is very confusing at first, because vscode highlights matched letters in the custom label if the same letters matched on the real file path. It seems like vscode is searching by the label, but it does not, making an impression as if the search is buggy, when it does not find a file.

Being able to search by custom label can be very convenient, because it allows quick narrowing down in large code base, like in my recording example with a prefix letter and colon at the beginning.

add: the ordering of the search results is also based on the original file path. This leads to seemingly arbitrary order when looking on the labels. The grouping seen in the recording are purely by chance, there are more items that come much further down the list.

As I understand this feature would require some indexing for the project. Maybe it can be an option in vscode, like:

{
  "workbench.editor.customLabels.search": true
  "workbench.editor.customLabels.sort": true
}
TylerLeonhardt commented 4 months ago

You've already enumerated the big issue with this...

As I understand this feature would require some indexing for the project

This is quite challenging. Today, we search through files on the filesystem using ripgrep... which knows nothing about custom labels... but it's super fast.

We'd need a solution that keeps the speed but also takes into consideration the custom label.

akomm commented 4 months ago

As @zardoy mentioned here in this is actually intended to be searchable:

https://code.visualstudio.com/updates/v1_89#_custom-editor-labels-in-quick-open

Your reply sound like its not an intended feature. Is there some misunderstanding on either side?

grafik

Sounds like its intended to search by custom label. Otherwise you're basically searching blind, when the labels make the actual path disappear, but the path is still being the one searched.

benibenj commented 4 months ago

The release note description might have been a bit misleading. We search files in the workspace based on the file paths but we then sort those results based on the custom label. We've seen that this works very well in most cases because users mostly change the label to use the words mentioned in the path. Also, when you have opened the file recently, it will also find the file just based on the custom label.

For example in the screenshot above, it finds the correct files because the word component appears in the file path, but it would also find it as it was recently opened.

To search the entire workspace based on the custom labels could be very slow due to custom labels using regex which is why we do not do this currently but we might explore this at some point. I apologize for any misunderstanding there might have been regarding this feature.

akomm commented 4 months ago

Thanks.

I have noticed that with recent files and it actually lead to even more initial confusion, because I was wondering why some paths work and some not. Until I've cleared the recent files. Though I have to admit that those search, sort and recent file confusions were cleared quite fast. Took me maybe 1-2mins of testing until it clicked.

In my case the labels are quite well readable but long, so the path isn't even visible and truncated. I wonder how edge-case or common-case my situation is.