bash-lsp / bash-language-server

A language server for Bash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

chrisgrieser opened this issue · comments

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

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.