fix: enum member declarations can now be renamed correctly. #2043
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2042.
Currently, renaming enum field members will return two duplicate edit actions in the LSP response.
On VSCode, this causes the editor to raise an error.
On Emacs, Neovim, and Helix, the edits made are incorrect.
The
symbolReferences
function tries to find all references to a declaration and the declaration itself (wheninclude_decls
flag is set). However, when searching for the references to an enum member like in here:The first identifier
zero
is treated first as a declaration and then also as a reference.This edge case can be handled by ensuring the name token for a symbol's declaration is never the same as its reference's name token.
Ideally, the
lookup
function should never be called for a container field init identifier, but the way AST traversal works right now, there is no straightforward way to figure out if the node we're currently on declares an enum member.Before:
Screen.Recording.2024-10-01.at.9.00.23.PM.mov
After:
Screen.Recording.2024-10-01.at.8.56.41.PM.mov