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

Cannot open md file with bash codeblock #2631

Closed
RobotSnowOtter opened this issue May 31, 2022 · 4 comments
Closed

Cannot open md file with bash codeblock #2631

RobotSnowOtter opened this issue May 31, 2022 · 4 comments
Labels
C-bug Category: This is a bug

Comments

@RobotSnowOtter
Copy link

Summary

Helix panics when opening markdown containing bash codeblocks (beginning with ```bash).

Reproduction Steps

Create a file bash.md containing the following:

```bash
echo hello world
```
  1. hx bash.md or :o bash.md from within helix

Error

thread 'main' panicked at 'Could not parse queries for language "bash". Are your grammars out of sync? Try running 'hx --grammar fetch' and 'hx --grammar build'. This query could not be parsed: QueryError { row: 48, column: 3, offset: 520, message: "expansion_flags", kind: NodeType }', helix-core/src/syntax.rs:384:43
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

--grammar fetch and --grammar build didn't solve it.

Removing runtime/queries/bash/highlights.scm allows the file to open.
Perhaps the problem lies with https://github.com/tree-sitter/tree-sitter-bash which is referenced in languages.toml, but that's where I found myself out of my depth.
Still, it seems strange that bash would crash a .md file.
If ```shell is used instead, that opens fine.

Helix log

n/a

Platform

Linux (Pop!_OS 22.04)

Terminal Emulator

gnome-terminal

Helix Version

helix 22.05 (fc666db)

@RobotSnowOtter RobotSnowOtter added the C-bug Category: This is a bug label May 31, 2022
@the-mikedavis
Copy link
Member

the-mikedavis commented May 31, 2022

You installed from source, yes? You'll need to re-link your runtime directory, preferrably with a symlink.

That error happens when the tree-sitter query analysis fails - in this case because the expansion_flags node doesn't exist. Your ~/.config/helix/runtime/queries/bash/highlights.scm is out of date and no longer compatible with the version of tree-sitter-bash specified in languages.toml, probably because of the update in #1917

@RobotSnowOtter
Copy link
Author

Thank you for your response and explanation.
At some point while troubleshooting I had copied the old language.toml into my .config/helix/ directory.
Removing that fixed the issue.
I appreciate your help!

@sudormrfbin
Copy link
Member

I think an error message displayed within the editor would be better than panicking here.

@the-mikedavis
Copy link
Member

I think even just kicking an error message to the logs and falling back to no highlight would be ok. It might be hard to figure out which query is failing and why if it's an error in the statusline since some of the error messages are long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

3 participants