From 63e602bda6e6c4381372880f4313aec46170044d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 7 Apr 2021 16:39:13 +0900 Subject: [PATCH] Fix issues with "enum A {|}" indent calculation. --- helix-core/src/indent.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 4bd644d4..659783ba 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -106,8 +106,11 @@ fn calculate_indentation(node: Option, newline: bool) -> usize { let parent_kind = parent.kind(); let start = parent.start_position().row; - // println!( - // "name: {}\tparent: {}\trange:\t{} {}\tfirst={:?}\tlast={:?} start={} prev={}", + // detect deeply nested indents in the same line + let starts_same_line = start == prev_start; + + // log::error!( + // "name: {}\tparent: {}\trange:\t{} {}\tfirst={:?}\tlast={:?} start={} prev={} same_line={}", // node.kind(), // parent.kind(), // node.range().start_point, @@ -116,14 +119,11 @@ fn calculate_indentation(node: Option, newline: bool) -> usize { // node.next_sibling().is_none(), // node.start_position(), // prev_start, + // starts_same_line // ); - // detect deeply nested indents in the same line - let starts_same_line = start == prev_start; - - if outdent.contains(&node.kind()) { + if outdent.contains(&node.kind()) && !starts_same_line { // we outdent by skipping the rules for the current level and jumping up - // println!("skipping.."); // node = parent; increment -= 1; // continue;