on master help sign in
Fix precedence order of @align captures in indent computation (#8659)
ef0c31dTriton171
helix-core/src/indent.rs+6−2
@@ -271,7 +271,9 @@ impl Indentation {
271 }
271 }
272
272
273 /// Add an indent capture to this indent.
273 /// 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).
275 fn add_capture(&mut self, added: IndentCaptureType) {
277 fn add_capture(&mut self, added: IndentCaptureType) {
276 match added {
278 match added {
277 IndentCaptureType::Indent => {
279 IndentCaptureType::Indent => {
@@ -295,7 +297,9 @@ impl Indentation {
295 self.outdent = 0;
297 self.outdent = 0;
296 }
298 }
297 IndentCaptureType::Align(align) => {
299 IndentCaptureType::Align(align) => {
300+ if self.align.is_none() {
298− self.align = Some(align);
301+ self.align = Some(align);
302+ }
299 }
303 }
300 }
304 }
301 }
305 }