From 74e4e52d84f23bd69a3356bf7a06fe7132ba7db7 Mon Sep 17 00:00:00 2001 From: Axel Kappel <69117984+Kl4rry@users.noreply.github.com> Date: Tue, 2 Jul 2024 21:57:31 +0200 Subject: [PATCH] make indent heuristic less agressive --- crates/ferrite-core/src/buffer.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/ferrite-core/src/buffer.rs b/crates/ferrite-core/src/buffer.rs index 80f6a76..4c4436a 100644 --- a/crates/ferrite-core/src/buffer.rs +++ b/crates/ferrite-core/src/buffer.rs @@ -1676,13 +1676,13 @@ impl Buffer { pub fn guess_indent(&self, byte_index: usize) -> String { let mut indent = String::new(); - let mut line_idx = self.rope.byte_to_line(byte_index); + let line_idx = self.rope.byte_to_line(byte_index); while line_idx > 0 { let line = self.rope.line(line_idx); - line_idx -= 1; + /*line_idx -= 1; if line.is_whitespace() { continue; - } + }*/ let mut new_indent = String::new(); for grapheme in line.grapehemes() { @@ -1696,15 +1696,15 @@ impl Buffer { break; } - let mut line_idx = self.rope.byte_to_line(byte_index) + 1; + let line_idx = self.rope.byte_to_line(byte_index) + 1; while line_idx > 0 { let Some(line) = self.rope.get_line(line_idx) else { break; }; - line_idx += 1; + /*line_idx += 1; if line.is_whitespace() { continue; - } + }*/ let mut new_indent = String::new(); for grapheme in line.grapehemes() {