-
-
Notifications
You must be signed in to change notification settings - Fork 389
Use AnnotatedTextEdits throughout HLS #3210
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
I would be interested in working on this @fendor |
Did you get anywhere @nilsalex ? |
We will need to not send these if clients don't understand them. I had an idea for that. We can always translate an We could potentially do this with something like this:
i.e. for a given method, given the capabilities relevant to that method, try to make the result we produced acceptable to the client by downgrading things. This could probably live in |
I played around with it a bit @michaelpj, switching to AnnotatedTextEdits for import list extensions (the place you suggested above). Without requiring confirmation, I could not see any visual difference, neither in VS Code, nor with coc.nvim. With confirmation required, VS Code shows a list of changes before optionally applying them. I'll push my experiments to my fork. |
That's a shame. I wish there was some guide in the spec showing what editors support what features, and what they actually do... |
AnnotatedTextEdit
s are a feature of the LSP spec that allow more structured edits to be returned. In particular:I haven't tested out what this looks like in the client, but in principle this should allow much nicer communication of what's going on with edits. For example, when adding imports for completions, we can annotate the edits for modifying imports to say what we're doing. The confirmation feature (if it actually works) seems nice for questionable or wide-ranging edits, like for renaming across modules.
We should try using them!
A good place to start would be here: https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs#L202, which sends a message to the user to tell them what we did. Hopefully an
AnnotatedTextEdit
would do that job better.The text was updated successfully, but these errors were encountered: