on master help sign in
Fix precedence order of @align captures in indent computation (#8659)

precedence when multiple occur on the same line in an indent query.

commitef0c31db02cc1ade81b6d5097f1d05d7b3fa85e5 authorTriton171 <daniel.ebert@protonmail.com> dateSun 29 Oct 2023, 17:48 (3 years ago) parentf992c3b
1 file changed+6−2
helix-core/src/indent.rs+6−2
helix-core/src/indent.rs+6−2
@@ -271,7 +271,9 @@ impl Indentation {
271271 }
272272
273273 /// Add an indent capture to this indent.
274− /// All the captures that are added in this way should be on the same line.
274+ /// Only captures that apply to the same line should be added together in this way (otherwise use `add_line`)
275+ /// and the captures should be added starting from the innermost tree-sitter node (currently this only matters
276+ /// if multiple `@align` patterns occur on the same line).
275277 fn add_capture(&mut self, added: IndentCaptureType) {
276278 match added {
277279 IndentCaptureType::Indent => {
@@ -295,7 +297,9 @@ impl Indentation {
295297 self.outdent = 0;
296298 }
297299 IndentCaptureType::Align(align) => {
298− self.align = Some(align);
300+ if self.align.is_none() {
301+ self.align = Some(align);
302+ }
299303 }
300304 }
301305 }