-
Notifications
You must be signed in to change notification settings - Fork 131
Go To Definition does not work (Bash IDE in VS Code) #646
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
Comments
Please include an example script. Unfortunately I can’t reproduce this error. |
I am using it in Visual Studio Code: Right Click > "Go to Definition" or CMD + Click |
A code example would still be great to know if this is an issue across files or jump to definition in a single file. Note that we recently https://github.com/bash-lsp/bash-language-server/blob/main/vscode-client/CHANGELOG.md#1210 started using source statements to narrow down the completions. If this is an issue across multiple files, then that could be the culprit. |
it does not work even inside a single file below a sample of code to check/test `#!/usr/bin/env bash func1() { |
Thanks for the example here. I couldn't reproduce any issues with that example using the latest extension. So I'm curious what is going on. Can I get you to upgrade to the latest version and paste the output from the extension? You can find the log output when opening a bash file and click "View -> Output -> Bash IDE". Try clicking jump to definition and paste the entire log output here. Thanks 🙏 |
sure...sorry for the late answer...many thx for your effort |
onDefinition 77:7 word="config_openssh" |
onDocumentHighlight 79:7 word="config_avahi" |
for the small sample text file was working.... |
I started "ShellCheck: Run Linting" and it seems that Go to Reference is working again (using latest version 1.23.0)! |
Hm. That isn’t a Bash IDE feature/option. But you see jump to definition working as expected now with the latest extension? |
Yes, working fine after executing "ShellCheck: Run Linting" - thank you |
Could you please reopen this case as "Go to Definition" only works up to 1.16.0 for projects opened locally or on a remote (ssh) server (for me and my college) |
@timoteicampian could you provide a reproducible example that always fails for you? The example above consistently works. Does jump to definition start working after you modify the file? |
Dear Kenneth
cat func.sh
cat init.0
Observation:
Suggestion: |
That means the we would suggest symbols an across the entire workspace, which if it contains more than a few bash files does give a rather cluttered and false suggestions/jump to definition. But the bahaviour is configurable. We default to analyze simple source statements, a feature that I wish to extend to analyze some dynamic sourcing and sourcing done inside functions. But if you prefer resolving symbols from the entire workspace you can use the I would like to understand how we can make this behaviour more clear to the end user. I believe the current default is sane, but that can be debated. But if we keep the current default we could show a warning on source statements that we cannot parse (I.e. “failed to analyze sourced file, resolution of symbols can be configured using…”) let me know how that sounds. |
And I would like to see examples of source statements from you project. :) |
|
setting true includeAllWorkspaceSymbols: z.boolean().default(true) does not help for the latest version. |
If I create the two files mentioned in #646 (comment) in a new workspace and enable I'm also curious which exact version that started breaking. You mention 1.18.0 working, but could you try 1.20.1? The behaviour of parsing source commands was first introduced in 1.21.0.
I've created #658 to capture this. Feel free to add additional input and ideas. |
@timoteicampian can you provide an example where enabling |
@timoteicampian A fix has now been released as [email protected] and the latest vscode extension 1.29.0. Let me know if it works for you and if you have ideas for future improvements. |
A feature that could benefit Bash IDE users greatly would be if the needed library source files to run a specific script would be automatically listed by Bash IDE - given a specific library folder where to choose from. |
@andreicaba sounds interesting. Could you write up an issue with additional detail? E.g. would these be suggestions after a |
OK, I did it :) |
works perfectly now - T H X ! ! - |
Sorry @skovhus to disappoint you, but I had to switch back to the stable (for me) version 1.18 again |
@timoteicampian could you share an example script that works in 1.18 but not in the latest version? The error logs just shows some files that fail to parse (I assume you removed the file names?) – I'm thinking they also failed to parse with version 1.18, so I'm curious to see some example code. |
they are working nice with 1.18 all the time :) |
That is great, but I would still like some example code to debug this. :) |
sure...I have uploaded a example file please check, I'll put soon much more if you need them |
I uploaded 2 script files + output of Bash IDE |
Thanks for the additional scripts. It turns out that for files where the treesitter parser fails, we didn't gracefully handle this in the later version of bash-language-server. I believe the error handling in the latest extension (1.30.0) is now the same as 1.18 – but including all the new improvements. Let me know if it works for you. |
same error for the same two files |
Note that the error logs are expected. In older versions this was shown as diagnostics (in the editor) if you enabling highlight parsing errors. So the syntax errors in the logs are expected. Anything that is working in the old version that isn’t working in the new version? If so please be specific with an example like “jump to definition on line X”. |
This is my findings: progress_bar.sh:
output_print.sh
So I conclude that 1.30 is an improvement to 1.18. Let me know if you find anything that works in 1.18, but not in 1.30. |
Dear @skovhus 1.18 works in my case for all scripts all the time :) |
Okay. The only thing I need in order to investigate and potentially fix the issue is concrete reproducible examples including what isn’t working in the latest version (steps to reproduce). As mentioned, then the two files here actually works better in the newest version. So I would appreciate more detailed examples of what isn’t working including some source files, then I’ll work on fixing the issues. |
Dear @skovhus, Let's say we want to source "file1" inside "run.sh".
|
That specific problem of including symbols from a sourced file without a file extension also doesn't work in 1.18. We use the background analysis glob (configurable) to analyze the workspace. But with the latest extension we actually do support parsing sourced files in case the the ExampleFile: x.sh
File: ./extension
|
A fix has been released in the vscode extension version 1.32, so in case |
Go to definition also doesn't work if a function is defined under where it's called. But - if it's about a library file, it shouldn't really be a problem to be called before the function is defined. And - actually - if it ever is to be signaled, this potential problem can be signaled by shellcheck and it doesn't seem to be a real need to be signaled by "Bash IDE" too (while I can understand that some people might want to use Bash IDE as a language server for this :) ) short example:
here g can be found inside h, but not inside f. |
Yeah that is a limitation of the current scope aware heuristic, implemented in #649 … The new heuristic should overall be better, where the previous one just found all symbols no matter the scope. That meant that jump to definition would jump to the latest definition in many cases. That being said: I would love to improve the heuristic based on your examples and feedback! Thanks for providing these. This specific case should be easy to fix.
My intention with improving the scope aware symbol resolution was never to signal problems to the end user but improve the overall experience by providing more accurate information — correct the previous sometimes confusing behaviour. See the different issues we fixed with the new heuristic: #649 What shellcheck does internally is actually flow tracing the scripts. I was hoping to avoid that complexity and provide something that would be “good enough” based on a few AST traversals. So any examples of scripts with incorrect behaviour is very welcome! |
Maybe it would be providing more accurate information if, after checking that the symbol is nowhere before, it would still provide a hyperlink to the function if it's defined afterward. |
@andreicaba can I get you to create a new issue capturing your suggestions for improving this or the bugs that you experience? That would be a huge help. |
Go To Definition does not work starting with version 1.19.0
The text was updated successfully, but these errors were encountered: