Unnamed repository; edit this file 'description' to name the repository.
Reduce weight of 1 space indents in indent detection (#14088)
Knoqx 7 months ago
parent ca4f638 · commit 2f7cc9d
-rw-r--r--helix-core/src/indent.rs6
1 files changed, 6 insertions, 0 deletions
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<IndentStyle> {
// 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
};