Clarify responses to rename request. by doriath · Pull Request #616 · microsoft/language-server-protocol (original) (raw)
Why?
First, let me explain why I would like to add this clarification here. ~2 months ago I was playing with RLS (Rust language server) and vim-lsp (client for vim) and I found that rename was not a great user experience.
Here is why:
- RLS returns
null
when rename did not succeed (for any reason). This also included cases like the code doesn't compile, so rename cannot be performed - vim-lsp does nothing when
null
is returned
This means that when I tried to rename something and it failed, I had no message telling me that something failed. From the client (vim-lsp) perspective, it is not clear how to interpret the null
response - was there just nothing to do, or was there some error and rename was not performed.
Alternative
In my Pull Request, I went with the proposal of treating null
as "nothing has to be done". The alternative approach could be to use it as generic "rename failed" indication.
If this one is preferred, I would propose:
- clarify that clients can treat this value as "can't perform rename at this position"
- generally discourage server implementations from returning null, in favor of returning clear error message. For example: the position is not at any symbol (e.g. space or brackets), current symbol does not support renames or the code doesn't compile.
After writing this explanation, I am slightly starting to lean toward the alternative proposal, but I will wait for the feedback first.