bash-lsp / bash-language-server

A language server for Bash
MIT License
2.08k stars 121 forks source link

((++SOMEVAR)) is not recognized as a usage of the SOMEVAR variable #510

Open Popkornium18 opened 2 years ago

Popkornium18 commented 2 years ago
declare -i SOMEVAR=0

# Hover and get references do not work with these statements
((++SOMEVAR))
((SOMEVAR++))
((SOMEVAR ++))

# But this works fine
((++ SOMEVAR))

Syntax-highlighting is also broken unless the fourth statement is used. Not sure if this means that it is a treesitter grammar issue and not a bashls issue.

Unfortunately shfmt also changes ((++ SOMEVAR)) to ((++SOMEVAR)).

skovhus commented 1 year ago

I cannot reproduce this anymore. Does it work for you @Popkornium18 ?

Popkornium18 commented 1 year ago

Yes, still broken for me.

Bottom one works. image

Others do not. image

I'm fairly certain it is treesitter producing bogus trees image

Shane-XB-Qian commented 1 year ago

the problem is the server treat the word is word="++SOMEVAR", the sent position is {'character': 4, 'line': 3} should be correct, so should be the keyword acknowledge obviously was wrong...

skovhus commented 1 year ago

Pasting this into https://tree-sitter.github.io/tree-sitter/playground also shows a tree sitter error node, so this clearly is a grammar bug.