bash-language-server
bash-language-server copied to clipboard
"Go to Definition" rarely works, Bash IDE output is full of "WARNING ⛔️ Error while parsing file"
Code editor
Visual Studio Code
Platform
Linux and macOS
Version
v1.37.0 (last working version was Bash IDE v1.28.0)
What steps will reproduce the bug?
It's triggered by so many scripts in one of my projects, I can't be sure there aren't other causes, but here's a trivial snippet that triggers the parsing error:
! VAR=
A less trivial example that's closer to how one might actually use a negated exit status:
! VAR=$(some-command | grep .) || printf '%s\n' "$VAR"
Interestingly, statements like ! ((VAR))
are parsed without issue.
How often does it reproduce? Is there a required condition?
This issue is reproducible 100% of the time.
What is the expected behavior?
Obviously the code should parse without triggering a syntax error, but in the event that it doesn't, output more specific than "[Warn - 20:12:15] 10:12:15.379 WARNING ⛔️ Error while parsing file:///path/to/file.sh: syntax error" -- even with the BASH_IDE_LOG_LEVEL
environment variable set to debug
, and the VS Code settings below -- would have saved a bunch of time using bisection to identify the problematic syntax 😬
{
"bashIde.logLevel": "debug",
"bashIde.enableSourceErrorDiagnostics": true
}
What do you see instead?
- "Go to Definition" and other LSP-serviced features fail for symbols in files that can't be parsed.
- No indication is given that anything is wrong. Problematic files appear to be problem-free in VS Code.
- In VS Code's output panel, "Bash IDE" reports "WARNING ⛔️ Error while parsing file:///path/to/file: syntax error" for many files during background scanning, and they continue whenever I'm editing a problematic file.
Additional information
No response
The parser used (tree-sitter) is by no means perfect. It keeps improving. But we specifically do no show parsing errors in the UI (as diagnostics) as there are too many false positives.
For most users the LSP works well for most script, but you might be using some bash constructs that are not supported yet in trees-sitter.
I’m unsure how we can provide a better error here. Any suggestions are more than welcome.
Same in NeoVim. I have a main
function on a script that calls other functions. Some are in a file that I am sourcing. Jump to definition works on all the functions located in the external file and only works on the main
function itself in the local file. It's very strange.
Same in NeoVim. I have a
main
function on a script that calls other functions. Some are in a file that I am sourcing. Jump to definition works on all the functions located in the external file and only works on themain
function itself in the local file. It's very strange.
I've found that if the function is called in the same file before it is defined, then jump to definition will not work.