Skip to content

'textDocument/rename' does not include variable references in (( )) (arithmetic) #1134

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

Closed
chrisgrieser opened this issue Mar 30, 2024 · 1 comment

Comments

@chrisgrieser
Copy link
Contributor

Code editor

nvim

Platform

macOS 14.1 (arm)

Version

5.1.2

What steps will reproduce the bug?

create a file with this code:

foo=123
foo=$((foo + 1))
echo "$foo"

renaming foo to bar results in this:

bar=123
bar=$((foo + 1))
echo "$bar"

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

References in a double bracket (()) should be affected by the renaming.

What do you see instead?

No reference in a double bracket (()) is affected by the renaming.

Additional information

No response

@mcecode
Copy link
Contributor

mcecode commented Apr 5, 2024

Hi. I'm the one who implemented rename symbol in #915.

One of the limitations I bumped into was that there are cases when variables are not typed properly as variables by the parser used (tree-sitter-bash) and therefore aren't picked up for renaming. Unfortunately, that's the case with this issue, the variable foo inside the arithmetic expansion isn't labelled by the parser as a variable and so it isn't renamed.

However, as indicated in #943, there's been a lot of fixes done recently to tree-sitter-bash and when trying out your code sample in the tree-sitter playground, foo in the arithmetic expansion is correctly typed as a variable. Currently, when looking at the parser.info file , it seems that we're using an old version of tree-sitter-bash (0.19.0) from 2022. I think this issue should be resolved when tree-sitter-bash is updated to the latest version (0.21.0), though I'm not sure if there are any blockers in doing that since #911 seems to indicate that there was a problem with upgrading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants