-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Freezes with 100% CPU when trying to open a specific Nix file #4862
Comments
This is probably from the tree-sitter-bash injections within strings. Tree-sitter-bash has an external scanner that looks like other problematic scanners we've seen (#3504, #3376, #2979), and looking at the source now, it looks like there is the usual workaround in place which prevents scanning if in error recovery: https://github.com/tree-sitter/tree-sitter-bash/blob/77cf8a7cab8904baf1a721762e012644ac1d4c7b/src/scanner.cc#L171-L191. We can probably fix this by updating tree-sitter-bash EDIT: we're already on a version of tree-sitter-bash with that scanner fix. It looks like updating tree-sitter-bash isn't enough to fix this. |
The "fix" also works in strings that are used as derivation names, or even when renaming variables. Even deleting things from the comment near the end makes the file openable. I don't think it's related to bash TS. |
Looking at a flamegraph for this, it looks like we're stuck on tree-sitter's If I comment out this block in nix injections then the problem goes away: helix/runtime/queries/nix/injections.scm Lines 21 to 28 in 590a628
The block I was pointing to in tree-sitter-bash isn't preventing scanning in error recovery, it's just part of the scanner 😅. Very strange that deleting from the comment removes the problem 🤔 |
It looks like this was a bug in tree-sitter itself and was fixed in tree-sitter/tree-sitter#1952 (also see nix-community/tree-sitter-nix#34). Running from that commit fixes this and the other linked issues for me. Once tree-sitter cuts a new version we should be able to upgrade and close this. (If you're building from source and want to use that change before it is published and updated within Helix, you can add a patch to the [patch.crates-io]
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "e021d6e9799903312dfa3a1ed39e160008fe52ac" } |
We could switch to a git dependency here too since tree-sitter hasn't been updated in 6 months. neovim did so too neovim/neovim#21858 |
Summary
Probably related to #2997
Reproduction Steps
Helix log
No response
Platform
Linux
Terminal Emulator
Tilix 1.9.5
Helix Version
helix 22.08.1
The text was updated successfully, but these errors were encountered: