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.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs
index bdf0f405..55454ebc 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;
@@ -214,10 +214,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 +243,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
}