-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Improve class member snippet completions and keyword completions interaction #52525
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
Conversation
|
Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary |
|
@typescript-bot pack this |
|
Hey @gabritto, I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
I know we talked about this before, but can you explain again why this is the case? Suppose you type wrong modifiers, and then trigger completions again after the modifiers. The |
I can't point to all the exact places in vscode where this happens, but from debugging, what I've seen happen is that vscode tries to match We could allow the wrong modifiers, or maybe just the wrong order, but if the restriction I described above is true and there's no way around it, then we can't fix the existing wrong modifiers. |
|
Sounds like an editor change that could be made? @mjbvz |
|
@typescript-bot run DT |
| let isSnippet: true | undefined; | ||
| let replacementSpan: TextSpan | undefined; | ||
| let insertText: string = name; | ||
| const filterText: string = name; |
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.
If filter text is name why cant editors use name itself to sort.. may need to considerkind along with that but it feels like we are returning same data.
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.
The editor doesn't know that it should use name as the filterText, because in theory filterText could be anything. We could change the TS vscode extension to use the name as the filterText for class member snippet completions, but then that change would be restricted to vscode, and other editors would potentially run into the problem this PR is trying to fix.
|
Ok, so I tried making the class member completions fix the existing modifiers with a code action. It doesn't look good because of the delay in applying the code action after the completion is inserted, so I'm not going to pursue that approach. So the options are, considering how vscode currently works with regards to
|
|
@typescript-bot test this |
|
Heya @gabritto, I've started to run the diff-based user code test suite on this PR at cc95bfc. You can monitor the build here. Update: The results are in! |
|
Heya @gabritto, I've started to run the diff-based top-repos suite (tsserver) on this PR at cc95bfc. You can monitor the build here. Update: The results are in! |
|
Heya @gabritto, I've started to run the diff-based user code test suite (tsserver) on this PR at cc95bfc. You can monitor the build here. Update: The results are in! |
|
Heya @gabritto, I've started to run the parallelized Definitely Typed test suite on this PR at cc95bfc. You can monitor the build here. Update: The results are in! |
|
Heya @gabritto, I've started to run the diff-based top-repos suite on this PR at cc95bfc. You can monitor the build here. Update: The results are in! |
|
@gabritto Here are the results of running the user test suite comparing Everything looks good! |
|
@gabritto Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
|
@gabritto Here are the results of running the top-repos suite comparing Everything looks good! |
|
Hey @gabritto, the results of running the DT tests are ready. |
|
@typescript-bot perf test this |
|
Heya @gabritto, I've started to run the perf test suite on this PR at cc95bfc. You can monitor the build here. Update: The results are in! |
|
@gabritto Here are the results of running the top-repos suite comparing Everything looks good! |
|
@gabritto Here they are:
CompilerComparison Report - main..52525
System
Hosts
Scenarios
TSServerComparison Report - main..52525
System
Hosts
Scenarios
StartupComparison Report - main..52525
System
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Fixes #52121.
This PR changes how class member snippet completions are sorted and filtered, and how they interact with class member modifiers.
The problem, as presented in the linked issue, is that class member snippet completions are currently sorted after keyword completions (via
sortText), and this is not ideal when you manually request completions inside a class without having typed anything (in other words, when you'd likely want to see the overridable class members first). However, this was done so that member completions that have modifiers do not show up before the modifier keywords when you are typing the modifier.With this PR, class member completions are sorted before keywords. But a class member
protected foo()will have a filter text offoo, meaning that, as you're typing, that member completion will only show up if you're typing a substring offoo(i.e. the editor will match what you're typing tofoo, whereas previously it would match what you're typing to the full insert text), so the member completion won't show up as you're typingprotected.I think in general this approach roughly matches what I've seen in other editors/languages (VS+C#, WebStorm+TS, xcode+Swift), and it makes sense to how I'd use it, but I'm looking for feedback on the UX and whether this is the best approach.
Case not supported:
asyncmodifier is not inserted/allowed. This has been the case since the initial implementation of class member snippet completions. It's not clear to me if/when we should insertasyncor allow it to be inserted, open for opinions on that. I vaguely recall that, regarding object method completions, the sentiment aroundasyncwas that we shouldn't insert it and people could add it after accepting the completion if they wanted.Not ideal:
publicProperty), it will be sorted before the modifier keyword. I'm hoping that's not common enough to be disruptive, but I might be wrong.How to test this in vscode:
filterTextis currently modified by vscode and not respected.