Skip to content
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

Broken highlighting for bash for one line variable assignment #3151

Closed
epbuennig opened this issue Jul 22, 2022 · 3 comments
Closed

Broken highlighting for bash for one line variable assignment #3151

epbuennig opened this issue Jul 22, 2022 · 3 comments
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR

Comments

@epbuennig
Copy link
Contributor

Summary

On a bash script file with two variable declarations on one line like this:

# in test.sh
x='' y=''

if true; then
fi

the highlighting breaks for subsequent lines.

Screenshots:

  • in neovim (looks the same for both cases)
    repro-nvim

  • in helix before
    repro-before

  • in helix after
    repro-after

Reproduction Steps

I tried this:

  1. create test.sh
  2. hx -vvv test.sh
  3. change x='' y='' to x=''y=''

I expected this to happen:

  • correct highlighting for before and after step 3

Instead, this happened:

  • incorrect highlighting before step 3
  • correct highlighting after step 3

Helix log

~/.cache/helix/helix.log
2022-07-22T16:29:56.597 helix_loader [DEBUG] Located configuration folders: []
2022-07-22T16:29:56.619 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE | WRITABLE
2022-07-22T16:29:56.619 mio::poll [TRACE] registering event source with poller: token=Token(2), interests=READABLE | WRITABLE
2022-07-22T16:29:56.619 mio::poll [TRACE] registering event source with poller: token=Token(3), interests=READABLE | WRITABLE
2022-07-22T16:29:56.619 mio::poll [TRACE] registering event source with poller: token=Token(4), interests=READABLE | WRITABLE
2022-07-22T16:29:56.619 mio::poll [TRACE] registering event source with poller: token=Token(5), interests=READABLE | WRITABLE
2022-07-22T16:29:56.619 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":false},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"publishDiagnostics":{},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":false}},"window":{"workDoneProgress":true},"workspace":{"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"workspaceFolders":true}},"processId":40892,"rootUri":null,"workspaceFolders":[]},"id":0}
2022-07-22T16:29:56.619 mio::poll [TRACE] registering event source with poller: token=Token(0), interests=READABLE
2022-07-22T16:29:56.619 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE
2022-07-22T16:29:56.788 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":4,"message":"Initialized server v. 3.0.5 for null"}}
2022-07-22T16:29:56.788 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Log, message: "Initialized server v. 3.0.5 for null" }
2022-07-22T16:29:56.857 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":1,"completionProvider":{"resolveProvider":true,"triggerCharacters":["$","{"]},"hoverProvider":true,"documentHighlightProvider":true,"definitionProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"referencesProvider":true}}}
2022-07-22T16:29:56.858 helix_lsp::transport [INFO] <- {"capabilities":{"completionProvider":{"resolveProvider":true,"triggerCharacters":["$","{"]},"definitionProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"hoverProvider":true,"referencesProvider":true,"textDocumentSync":1,"workspaceSymbolProvider":true}}
2022-07-22T16:29:56.858 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2022-07-22T16:29:56.858 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"bash","text":"x='' y=''\n \nif true; then\nfi\n","uri":"file:///home/erxkk/test.sh","version":0}}}
2022-07-22T16:29:56.860 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"workspace/workspaceFolders","params":null}
2022-07-22T16:29:56.860 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[],"id":0}
2022-07-22T16:29:56.866 helix_lsp::transport [ERROR] err <- "shellcheck not available at path 'shellcheck'\n"
2022-07-22T16:29:56.866 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/erxkk/test.sh","diagnostics":[]}}
2022-07-22T16:30:00.453 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"x=''y=''\n \nif true; then\nfi\n"}],"textDocument":{"uri":"file:///home/erxkk/test.sh","version":1}}}
2022-07-22T16:30:00.457 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"method":"workspace/workspaceFolders","params":null}
2022-07-22T16:30:00.457 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[],"id":1}
2022-07-22T16:30:00.459 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/erxkk/test.sh","diagnostics":[]}}
2022-07-22T16:30:05.504 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"shutdown","params":null,"id":1}
2022-07-22T16:30:05.506 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"result":null}
2022-07-22T16:30:05.506 helix_lsp::transport [INFO] <- null
2022-07-22T16:30:05.507 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"exit","params":null}
2022-07-22T16:30:05.510 mio::poll [TRACE] deregistering event source from poller
2022-07-22T16:30:05.510 mio::poll [TRACE] deregistering event source from poller
2022-07-22T16:30:05.512 mio::poll [TRACE] deregistering event source from poller
2022-07-22T16:30:05.512 mio::poll [TRACE] deregistering event source from poller
2022-07-22T16:30:05.512 mio::poll [TRACE] deregistering event source from poller

Platform

Linux 5.18.12-arch1-1

Terminal Emulator

alacritty 0.10.1 ()

Helix Version

helix 22.05

@epbuennig epbuennig added the C-bug Category: This is a bug label Jul 22, 2022
@epbuennig
Copy link
Contributor Author

If this issue must be fixed on helix's side and is a good first issue then I'd love to tackle it.

@sudormrfbin
Copy link
Member

This seems to be an issue with tree-sitter-bash: tree-sitter/tree-sitter-bash#123.

@sudormrfbin sudormrfbin added upstream A-tree-sitter Area: Tree-sitter labels Jul 22, 2022
@pascalkuthe pascalkuthe added E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR and removed upstream labels Apr 16, 2024
@pascalkuthe
Copy link
Member

This has been fixed upstream but our bash Grammer simply hasn't been updated for 2 years.

This should mostly be a matter of bumping the commit in languages.toml but you would also need to check whether any query changes are necessary by the changes in the grammar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR
Projects
None yet
Development

No branches or pull requests

3 participants