Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-core/src/indent.rs')
| -rw-r--r-- | helix-core/src/indent.rs | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index bdf0f405..c9415d1d 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, collections::HashMap}; +use std::{borrow::Cow, collections::HashMap, iter}; use helix_stdx::rope::RopeSliceExt; use tree_house::TREE_SITTER_MATCH_LIMIT; @@ -153,12 +153,6 @@ 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 }; @@ -214,10 +208,7 @@ fn whitespace_with_same_width(text: RopeSlice) -> String { if grapheme == "\t" { s.push('\t'); } else { - s.extend(std::iter::repeat_n( - ' ', - grapheme_width(&Cow::from(grapheme)), - )); + s.extend(std::iter::repeat(' ').take(grapheme_width(&Cow::from(grapheme)))); } } s @@ -246,10 +237,10 @@ pub fn normalize_indentation( original_len += 1; } if indent_style == IndentStyle::Tabs { - dst.extend(std::iter::repeat_n('\t', len / tab_width)); + dst.extend(iter::repeat('\t').take(len / tab_width)); len %= tab_width; } - dst.extend(std::iter::repeat_n(' ', len)); + dst.extend(iter::repeat(' ').take(len)); original_len } |