From 0fc257184561c41a5e6972f7f5e1c89635230bd7 Mon Sep 17 00:00:00 2001 From: Triton171 Date: Sun, 29 Oct 2023 17:48:58 +0100 Subject: [PATCH] Fix precedence order of @align captures in indent computation (#8659) precedence when multiple occur on the same line in an indent query. --- helix-core/src/indent.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 6ccdc5952377..abf45d6faf36 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -271,7 +271,9 @@ impl Indentation { } /// Add an indent capture to this indent. - /// All the captures that are added in this way should be on the same line. + /// Only captures that apply to the same line should be added together in this way (otherwise use `add_line`) + /// and the captures should be added starting from the innermost tree-sitter node (currently this only matters + /// if multiple `@align` patterns occur on the same line). fn add_capture(&mut self, added: IndentCaptureType) { match added { IndentCaptureType::Indent => { @@ -295,7 +297,9 @@ impl Indentation { self.outdent = 0; } IndentCaptureType::Align(align) => { - self.align = Some(align); + if self.align.is_none() { + self.align = Some(align); + } } } }