zed icon indicating copy to clipboard operation
zed copied to clipboard

'Rename Symbol" command doesn't rename all the occurrences

Open Jeordanis opened this issue 1 year ago • 17 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

Renaming a symbol local to a function doesn't rename all the occurrences.

Video:

https://github.com/zed-industries/zed/assets/145113/23f599ef-c4d4-4f33-bd58-20bec295fcb5

Notice how some of the occurrences are not renamed.

Environment

Zed: v0.120.5 (Zed) OS: macOS 14.2.0 Memory: 32 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

Jeordanis avatar Feb 01 '24 01:02 Jeordanis

I believe this affects more than just C and C++. Here I've recorded a video of a similar thing happening in Ruby:

https://github.com/zed-industries/zed/assets/77887/7719a29b-c747-4469-867f-548d9ad2c4e4

You can see in my example, in addition to missing one of the occurrences, it also "doubles" the change on the first instance (I tried initiating a rename on the last instance, and it still doubles the first one, not the one I initiated from).

willcosgrove avatar Mar 07 '24 19:03 willcosgrove

Renaming is not working at all with me for some previous versions, after changing pressing Enter or CMD + Enter makes nothing.

xcrap avatar Mar 25 '24 23:03 xcrap

Renaming is not working at all with me for some previous versions, after changing pressing Enter or CMD + Enter makes nothing.

Same here

philippfrank avatar Mar 29 '24 10:03 philippfrank

Renaming is not working at all with me for some previous versions, after changing pressing Enter or CMD + Enter makes nothing.

Same here

FomasTreeman avatar Jun 19 '24 15:06 FomasTreeman

Hi @Jeordanis,

I've noticed that in your video there are a bunch of squiggles (I assume clangd: use of undeclared identifier). In attempting to reproduce this issue I observed the clangd language server rename functionality does not function properly when it has a bunch of unindentified symbols.

On the other hand, when those stubbed it behaves as expected:

https://github.com/zed-industries/zed/assets/145113/3856f8ba-5538-4d11-80b3-323a85cd7bde

notpeter avatar Jul 09 '24 19:07 notpeter

Renaming is not working at all with me for some previous versions, after changing pressing Enter or CMD + Enter makes nothing.

Also not working for me. Rename symbol (both in vim and standard mode) does nothing.

Edit: just tested, it works in Python, but not in Elixir, so the problem is elixir (maybe even elixir-ls) specific.

Zed 0.143.6 Linux

Benjamin-van-Heerden avatar Jul 11 '24 21:07 Benjamin-van-Heerden

Zed 0.163.2 I confirm Rename symbol does not work (Rust)

PeterVajda87 avatar Dec 01 '24 14:12 PeterVajda87

This was such a big feature it would be very important if they could check and prioritise this.

xcrap avatar Dec 01 '24 16:12 xcrap

Can anyone create a minimal repo which can reproduce this issue? The core of rename functionality is handled by the language server (which works for me in Rust with rust-analyzer) but there's obviously Zed code involved in resolving the edits which could be failing with some projects/environments. My previous comment demonstrates one such case (clangd doesn't handle renames properly when there missing/unresolved symbols involved) but I wonder if there are others.

Since there are multiple people reporting issues in multiple languages I'd love to see if we can get to the bottom of this.

notpeter avatar Dec 02 '24 15:12 notpeter

Well mine it's with PHP, i remembering working in the initial versions but since months ago it stopped working and never returned. I've just tried again with the same issue, with me it does not replace nothing, not even the selected symbol itself. I bet if you create a php file with a function the results should be the same.

xcrap avatar Dec 03 '24 14:12 xcrap

Same issue for PHP. It doesn't replace anything

ruskiiamov avatar Jan 21 '25 10:01 ruskiiamov

We're unable to reproduce this internally (with Rust/Go/Typescript/Python).

Rename is provided by the LSP, so it does seem plausible that there are cases where it's not working; but to make more progress we'll need a repo/file that reproduces the problem.

Does anyone have something they could share?

ConradIrwin avatar Jan 30 '25 16:01 ConradIrwin

It still has bugs in PHP.

If I'm using intelephense I get this:

Image

I'm using the pro version and it does support renaming symbols.

Even disabling and using the default phpactor it's strange, renaming works inside classes but does not work with single functions for example.

PS: Just to keep in mind renaming worked perfectly in all scenarios (I think it used intelephense back then) before Zed moved PHP into an extension. In VScode it's working normally with intelephense in all scenarios.

xcrap avatar Jan 31 '25 04:01 xcrap

See the same issue with Ruby + ruby-lsp. I can select the word, see LSP highlight the other matching words, enter renamed value, try to confirm it via selecting "Editor: confirm rename" or pressing "Enter". In either case, the "rename" line goes away, and all words (including the word I selected for rename) stay unchanged.

maxim avatar Apr 01 '25 17:04 maxim

See the same issue with Ruby + ruby-lsp. I can select the word, see LSP highlight the other matching words, enter renamed value, try to confirm it via selecting "Editor: confirm rename" or pressing "Enter". In either case, the "rename" line goes away, and all words (including the word I selected for rename) stay unchanged.

This is what I see when renaming in Scala too -- I enter the new name, press enter and everything is as it was before

malcolmredheron avatar May 15 '25 17:05 malcolmredheron

Rename is implemented in the language server. Zed sends textDocument/rename and then the LSP replies with a list of documentChanges (and potentially file renames or other changes), which Zed then applies to the buffer and sends textDocument/didChange back to the LSP when the edits have been applied.

Can you take a look at debug: language server logs, choose your LSP and open RPC messages to see more. Is there anything in your Zed.log when this happens?

Can anyone provide a trivial repo + steps which reproduces this behavior?

notpeter avatar May 16 '25 08:05 notpeter

Can anyone provide a trivial repo + steps which reproduces this behavior?

I'm using Mill + Metals (https://scalameta.org/metals/docs/build-tools/mill/). To try to get you a reproducible case, I just removed my .bsp and .metals directories and re-opened the project. And now renaming works. That's probably frustrating for you, but I'm happy! Hopefully this helps someone else

malcolmredheron avatar May 16 '25 20:05 malcolmredheron

I'm going to go ahead and close this as unactionable. Individual language servers have varying levels of support for this and some are not able to find all references to filenames consistently.

If anyone can come up with reproducible steps from an empty folder in a repo for a particular LSP please open a clean issue and I'd love to dive in.

Thanks all!

notpeter avatar Jun 04 '25 20:06 notpeter