-
Notifications
You must be signed in to change notification settings - Fork 184
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
Experimental Workspace Symbols overhaul #2333
Conversation
Update:
Has anybody tried out this branch yet, or is the implementation too "hacky"? I think it could be a nice UX improvement. |
No, I haven't tried it. |
I'm impressed with your persistence in getting this working against all odds (ST limitations) :) After quick testing I've noticed that we are loosing fuzzy filtering in the process. Previously you would search for a symbol (in a non-fuzzy way typically) and get a list with results that could be filtered in a fuzzy way. Now the query both does a query against the server and filters so no longer works that way. Not sure how acceptable that is. |
Yeah, that is right. But as you say, with the previous way there is also no fuzzy matching when you type the query (unless implemented by the server itself), so if you made a typo there or don't really know the exact symbol name, it might also show no relevant results from the server. And in general I would not say that the usability of the previous implementation with the two-step procedure is better in any way. If you want to make use of the fuzzy matching, then you have to type the input twice; first in the query field and after that again when the results are show. And there is no quick way to get back to the query text. I've checked VS Code too, and there seems to also be no fuzzy matching for the "Go to Symbol in Workspace" feature (at least when it uses the |
Yes, this empty item is needed as a trick to select the topmost row instead of the first item of the list, see sublimehq/sublime_text#6162 (comment). If my suggestion from the issue report maybe gets implemented in the future, we could remove this empty item, but for now this was the only workaround I found.
Nice idea, added. |
I tried this a bit and it’s already a big improvement over the previous implementation! I vote to merge this. |
I tried to fix the volatile width of the command palette after updating the list items, but I couldn't find a way to do it. The command palette keeps a constant width when you manually go back in an input handler with Backspace and then open the command again, and even if the length of the longest list item is now different. But I found no way to do that programatically, because there is no command to pop an input handler from the input stack. I tried to workaround that via Nevertheless I'll mark the PR as ready, so you could review if you want. |
Sometimes, it can happen that the text in the palette gets deleted: For example I was typing |
I think I know what causes this bug. When an InputHandler is shown in the command palette, with a non-empty # --- Hack needed because the initial_selection method is not supported on Python 3.3 API
selection = self.input_view.sel()
selection.clear()
selection.add(len(self.text))
# --- End of hack But this cannot run in Now the problem is that apparently there is a very small timespan where the input field was just created, with the whole text still selected, and a key press event when typing another character gets recognized at the same time. In that case it will replace the whole input text, before the I have opened an issue for the Removed the workaround from above (meaning that the PR is only usable with a fixed |
I just wanted to tell that the UX is gold. |
I still think we are loosing something (fuzzy filtering) in the process which makes me a little hesitant about this change. Before we could do a basic query to get a lot of symbols and then filter it more with fuzzy matching. Now the fuzzy matching is suppressed by server results. Screen.Recording.2023-11-09.at.23.36.55.movThough to be fair i pretty much never use LSP's "Goto in project" because of that two-step flow and because Sublime's own implementation is good enough typically so I'm fine with others overriding me on this one. |
Yes, I already partially answered in #2333 (comment). But it depends on the server, for example Pyright does support fuzzy matching. Some servers might even support special query patterns, though I don't know if there is any example for that. This would probably not work with this PR due to being filtered out by ST matching. Another related discussion: microsoft/language-server-protocol#1674 So the question is which UX is the better one, the previous two-step behavior with fuzzy matching after the query string, or the dynamic input from this PR, possibly without the fuzzy matching. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this more than the current behavior
I've marked the PR as ready again, so you could decide whether it should be merged or not, or maybe there are still some suggestions for modifications. The bug mentioned above with the deleted input should be fixed now both on stable and dev ST builds, and it should happen only very rarely for older builds. One point which I think was not discussed above, is that with this PR there is no way anymore to send an empty query string to the server. In theory the behavior could easily be changed to always send a request with empty query when the command is run, but I decided to not do that because probably in 99% of cases the user will start typing anyway when the input handler gets opened, and when the response from the empty query arrives it would most likely already be outdated. And I guess that the request with empty query, i.e. all symbols in the project, is rather expensive, so it might not be the best idea to do this. |
I would merge this till the end of the week if no one has anything against it. |
Here is another hack from me. Or maybe let's call it a creative way of using the ST API, rather than a hack ;-)
I prefer the ST native "Goto Symbol in Project" over the LSP variant, because for the latter you have to type the query text first, before the results are shown. So I basically never use the one from LSP.
This PR allows to fetch and show the results of the "LSP: Goto Symbol in Project" command before you hit Enter. And I think the PR could also make it possible to support partial results for the workspace symbols request, though I haven't looked into that yet.
This was a bit of an experiment and it might have some strange behaviors. So for now I created this PR as a draft, and we can see if it can be improved, or otherwise close it and hope that one day ST will implement such a panel natively (sublimehq/sublime_text#3338). But I think it is an interesting approach and has some potential. Maybe I will revisit it at a later time.
Current drawbacks in this implementation are: