From 2f7cc9d0ae322a799e1b760f71b954e02dfdbae3 Mon Sep 17 00:00:00 2001 From: Knoqx <43473765+Quplet@users.noreply.github.com> Date: Sun, 27 Jul 2025 18:36:18 -0400 Subject: [PATCH] Reduce weight of 1 space indents in indent detection (#14088) --- helix-core/src/indent.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index c9415d1d..55454ebc 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -153,6 +153,12 @@ pub fn auto_detect_indent_style(document_text: &Rope) -> Option { // Give more weight to tabs, because their presence is a very // strong indicator. histogram[0] *= 2; + // Gives less weight to single indent, as single spaces are + // often used in certain languages' comment systems and rarely + // used as the actual document indentation. + if histogram[1] > 1 { + histogram[1] /= 2; + } histogram }; -- 2.51.2