aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
authorTriton1712023-10-29 16:48:58 +0000
committerGitHub2023-10-29 16:48:58 +0000
commitef0c31db02cc1ade81b6d5097f1d05d7b3fa85e5 (patch)
tree27d8bf29aa2c1d08a0ff18f6314dba9ea0859da1 /helix-core/src
parentf992c3b5972dbe2432ceb55bc8d47fed912f88bf (diff)
Fix precedence order of @align captures in indent computation (#8659)
precedence when multiple occur on the same line in an indent query.
Diffstat (limited to 'helix-core/src')
-rw-r--r--helix-core/src/indent.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs
index 6ccdc595..abf45d6f 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);
+ }
}
}
}