-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Odd quick fix ordering for misspelled identifiers #27614
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
Comments
The ordering of fixes is currently determined by the load order of files, since they each immediately alter global state the moment they're loaded. I think we should change these files to export an object instead of calling |
I'd like to give this one a shot if no one's working on it. This is my first issue so I would really appreciate it if someone could direct me to the files I should look at to fix this. |
@jrkong you just have to change the ordering of the codefix files in the various |
@RyanCavanaugh thanks a lot! That really helps, I'll do some digging. |
So after spending a bit of time with the code I've discovered some odd inconsistencies with the behavior for this particular bug: When I attempt to reproduce the bug with the given line in the issue this is what I see: However if I added the lines:
@DanielRosenwasser could you verify if I've reproduced the bug properly? Here's where things got really odd for me:Looking at the So in theory I deliberately tried testing against the incorrect output to verify the behavior of the bug before I made any further changes but the tests seem to imply that |
I looked at the tsserver logs and it looks like the editor is making two separate calls:
So the ordering of our results is irrelevant because we're only returning one result at a time. |
Is this issue still up for grabs? @DanielRosenwasser |
I think from the conversation above, this issue is too involved and needs some actual discussion at an editor sync first. |
One idea we had in the editor sync: an editor could ask about diagnostics with narrower spans than wider spans. Another: an editor could provide multiple diagnostics and ranges it's interested in fixing in one call; that way the server could fix this. Another-nother idea: editor provides a range, TypeScript just tries to fix all error codes. Another-nother-nother idea: because error spans can drift, it might be better to just ask for the error code. But overall, we need to get a better idea from how editors have implemented this. There might be some inspiration from how refactorings work. |
I believe that "misspelled identifier" quick fixes should precede the "remove unused declarations".
If anyone wants to take this on, this should just be a matter of
The text was updated successfully, but these errors were encountered: