-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Renaming lifetimes doesn't work (protocol error: InvalidParams: Invalid name pallete_view: not a lifetime identifier) #6060
Comments
What’s your Rust-analyzer version ? |
[dogunbound@archlinux ~]$ rust-analyzer --version |
Could you try it with the most recent one (either building it from source or using the latest release), to see if you reproduce ? |
Still getting: |
It looks like rust-analyzer needs the |
As true as this is, helix isn't telling my I need the ' character, nor does it automatically put a ' character at the front of the replace. This is a helix bug imo |
You would expect to see This was discussed a bit in #2459: we use the current word as an approximation of the symbol. Adding support for LSP Prepare Rename (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_prepareRename) would most likely give us the range of |
It's a helix issue to not auto-fill the rename with |
2023-02-20.17-41-37.mp4 |
Helix has no concept of a lifetime or anything rust/language specific. As @the-mikedavis said the way to implement this is to add support for https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_prepareRename to helix. I don't think word would work as |
I started trying to implement PrepareRename for pre-filling the prompt but got stuck on the way callbacks work within this code. My changes are here. The issue I'm having is I need to use a callback to wait for the response from prepare_rename before starting a rename prompt, but I can't move Context between threads, which all the prompt compositor code requires. @the-mikedavis @pascalkuthe do you have any insights here? Thanks! |
I started down another path (here, very "crashy") where I block for the response to PrepareRename in the main thread. It's a bit laggy if you do this while the LSP is initializing, however it does work. What's interesting is the range provided by the LSP does not include the
(I have no idea how rust-analyzer versions work.) I still think my WIP branch is worth pursuing since PrepareRename is more likely to be correct than just expanding a word boundary, at least for some languages. |
You will want to use |
Thanks @the-mikedavis! I appreciate the help, look forward to seeing what I had wrong with the borrowck and range selection rules. Edit: This must be unique to my version of rust-analyzer or something. With your branch as well, I am asked to rename e.g. |
Summary
Make a struct with lifetime requirements. Try renaming them with
<space>-r
. You should get this error: protocol error: InvalidParams: Invalid name pallete_view: not a lifetime identifier2023-02-19.16-40-14.mp4
Reproduction Steps
Open file with helix
make a struct with lifetimes, or use this one:
Try renaming
'lifetime_1
to'a
with<space>-r
Helix log
helix.log
Platform
Linux
Terminal Emulator
Konsole
Helix Version
22.12
The text was updated successfully, but these errors were encountered: