Reduce weight of 1 space indents in indent detection (#14088)

This commit is contained in:
Knoqx
2025-07-27 18:36:18 -04:00
committed by GitHub
parent ca4f638dfd
commit 2f7cc9d0ae

View File

@@ -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
};