helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
32.93k stars 2.43k forks source link

Rust HRTB breaks smart indent #7695

Open kawadakk opened 1 year ago

kawadakk commented 1 year ago

Summary

Smart indent misbehaves when editing a Rust source file containing RPIT with HRTB.

Reproduction Steps

Execute o (open new line below selection) with a single cursor located anywhere inside line 1: ```rust fn foo() -> impl for<'a> PartialEq<&'a str> { std::process::abort() as &str } ``` I expected this to happen: The new line is pre-indented to match the indentation of the existing statement. Instead, this happened: The new line is not pre-indented, and the cursor moves to the leftmost column. ### Helix log ~/.cache/helix/helix.log: (no relevant outputs found) ### Platform Linux ### Terminal Emulator tmux / Wez's Terminal ### Helix Version helix 23.05
pascalkuthe commented 1 year ago

this is an upstream issue it seems the rust grammar can't parse this code correctly and emits error nodes (it doern't even recognize this as a function). Sadly TS parsers are much less error resistant than ideal (RA approach to paring is much more robust but doesn't really work with a parser generator, this issue is basically what is explained here). This will break all TS functionality as a result