Closed sevenautumns closed 1 year ago
Unable to reproduce.
Linux 5.15.60-1-MANJARO @ 21.3.7 Kitty 0.25.2 helix 22.08.1 (23027a45) rnix-lsp 0.2.5-1
Which rnix-lsp
are you on?
Seems to trigger if the start of the range is past the end of the range or if ranges overlap:
for (i, range) in ranges.iter().enumerate() {
if range.start_byte < prev_end_byte || range.end_byte < range.start_byte {
return Err(IncludedRangesError(i));
}
prev_end_byte = range.end_byte;
}
I also can't replicate: which =
sign on this line? https://github.com/helix-editor/helix/blob/03612174ee4cef23217b5adf415ced4a851b4a44/flake.nix#L31 Do you have auto-pairs disabled?
I don't think it has anything to do with the LSP, this is a tree-sitter parsing issue.
There's a flake.nix linked in the initial post, it's collapsible so easy to miss. I could reproduce the crash with it (on mobile right now so can't get the hx --version
).
I tested that file with 32ggf=a'
and I simply just get the normal diagnostic error message. Do you have another set of keys you use to trigger the error?
@AlexanderBrevig I am on rnix-lsp 0.2.5.
Do you have another set of keys you use to trigger the error?
At least for me there are no keys required at all. I tested adding the '
with another language selected. It works, but when I reopened the file afterwards helix would just straight up crash.
@archseer
Do you have auto-pairs disabled?
I do not have auto-pairs disabled. I'll provide my config here:
Other than these settings, default from 0361217 are used
@AlexanderBrevig
Here is a flake.nix which just straight up crashes helix.
With #3826 of course the output of the program changes to:
It looks like this was introduced by 665e27ff9dc017ee47f646187d98f5e4cdb18411
minimal reproduction:
{
startup.hook = ''
sh
''
}
I assume it has something to do with this: https://github.com/helix-editor/helix/blob/eb81cf3c013232fb1b01c51e9f3edba4cf39d977/runtime/queries/nix/injections.scm#L17 I'll dig into it a little bit later
looking at this the query: https://github.com/helix-editor/helix/blob/eb81cf3c013232fb1b01c51e9f3edba4cf39d977/runtime/queries/nix/injections.scm#L11-L19 matches twice for the above nix text
QueryMatch { id: 0, pattern_index: 2, captures: [QueryCapture { node: {Node identifier (1, 2) - (1, 9)}, index: 2 }, QueryCapture { node: {Node string_fragment (1, 19) - (3, 2)}, index: 0 }] }
QueryMatch { id: 1, pattern_index: 2, captures: [QueryCapture { node: {Node identifier (1, 10) - (1, 14)}, index: 2 }, QueryCapture { node: {Node string_fragment (1, 19) - (3, 2)}, index: 0 }] }
so there is duplicated content nodes
[{Node string_fragment (1, 19) - (3, 2)}, {Node string_fragment (1, 19) - (3, 2)}]
which creates duplicated ranges: https://github.com/helix-editor/helix/blob/eb81cf3c013232fb1b01c51e9f3edba4cf39d977/helix-core/src/syntax.rs#L1192-L1197
adding ranges.dedup();
after the above line did fix this issue but I am pretty sure that is not the correct fix
Summary
When adding a
'
-symbol to a specific line of a specific nix-file, the predefined language-server for nix files (rnix-lsp) seems to provide information which results in an error in the tree_sitter parser which is unwrapped and hence panics.https://github.com/helix-editor/helix/blob/03612174ee4cef23217b5adf415ced4a851b4a44/helix-core/src/syntax.rs#L988
Reproduction Steps
I tried this: 1. `hx flake.nix` 2. go to line 32 3. add `'` after the `=`-symbol of that line 4. crashflake.nix
```nix { inputs = { utils.url = "github:numtide/flake-utils"; devshell.url = "github:numtide/devshell"; fenix.url = "github:nix-community/fenix"; fenix.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, utils, devshell, fenix, ... }@inputs: utils.lib.eachSystem [ "aarch64-linux" "i686-linux" "x86_64-linux" ] (system: let pkgs = import nixpkgs { inherit system; overlays = [ devshell.overlay ]; }; rust-toolchain = with fenix.packages.${system}; combine [ stable.rustc stable.cargo stable.clippy stable.rustfmt ]; in rec { devShells.default = (pkgs.devshell.mkShell { imports = [ # "${devshell}/extra/language/rust.nix" "${devshell}/extra/git/hooks.nix" ]; name = "apex-rs-vanilla-dev-shell"; packages = with pkgs; [ rust-toolchain rust-analyzer cargo-outdated cargo-udeps ]; devshell.startup.bindgen-hook.text = "source ${pkgs.rustPlatform.bindgenHook}/nix-support/setup-hook && populateBindgenEnv"; git.hooks = { enable = true; pre-commit.text = "nix flake check"; }; commands = [ { package = "git-cliff"; help = "Changelog generator"; } { package = "treefmt"; help = "Format project tree with recommended formatter"; category = "formatter"; } { name = "udeps"; command = "cargo-udeps udeps"; category = "formatter"; help = "Find unused dependencies in Cargo.toml"; } { name = "outdated"; command = "cargo-outdated outdated"; category = "formatter"; help = "Find out-of-date dependencies"; } { name = "build"; command = "cd $PRJ_ROOT && cargo build"; help = "Build project"; category = "build"; } { name = "build release"; command = "cd $PRJ_ROOT && cargo build --release"; help = "Build project in release mode"; category = "build"; } { name = "clippy"; command = "cd $PRJ_ROOT && cargo clippy"; help = "Build project"; category = "build"; } { name = "clippy release"; command = "cd $PRJ_ROOT && cargo clippy --release"; help = "Build project in release mode"; category = "build"; } { name = "watch"; command = "cd $PRJ_ROOT && cargo watch -x clippy"; help = "Watch project and continuesly clippy"; category = "build"; } { name = "watch release"; command = "cd $PRJ_ROOT && cargo watch -x clippy --release"; help = "Watch project and continuesly clippy in release mode"; category = "build"; } ]; }); checks = { nixpkgs-fmt = pkgs.runCommand "nixpkgs-fmt" { nativeBuildInputs = [ pkgs.nixpkgs-fmt ]; } "nixpkgs-fmt --check ${./.}; touch $out"; cargo-fmt = pkgs.runCommand "cargo-fmt" { nativeBuildInputs = [ rust-toolchain ]; } "cd ${./.}; cargo fmt --check; touch $out"; }; }); } ```~/.cache/helix/helix.log
``` 2022-09-12T15:24:49.391 helix_lsp::transport [ERROR] err: <- StreamClosed 2022-09-12T15:24:49.391 helix_lsp::transport [ERROR] err: <- StreamClosed ```console output
``` ❯ RUST_BACKTRACE=full hx flake.nix thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: IncludedRangesError(1)', helix-core/src/syntax.rs:988:50 stack backtrace: 0: 0x55e7021044d4 -