1
0
Fork 0
mirror of https://github.com/helix-editor/helix synced 2024-06-12 20:46:17 +02:00

commands: use chars().count() over .len() on strings

This commit is contained in:
Blaž Hrastnik 2021-06-07 09:26:49 +09:00
parent ff8a031cb2
commit 01b1bd15a1

View File

@ -1220,7 +1220,7 @@ fn open(cx: &mut Context, open: Open) {
let text = text.repeat(count);
// calculate new selection range
let pos = index + text.len();
let pos = index + text.chars().count();
ranges.push(Range::new(pos, pos));
(index, index, Some(text.into()))
@ -1811,7 +1811,7 @@ pub fn insert_newline(cx: &mut Context) {
text.push('\n');
text.push_str(&indent);
let head = pos + offs + text.len();
let head = pos + offs + text.chars().count();
// TODO: range replace or extend
// range.replace(|range| range.is_empty(), head); -> fn extend if cond true, new head pos
@ -1833,7 +1833,7 @@ pub fn insert_newline(cx: &mut Context) {
text.push_str(&indent);
}
offs += text.len();
offs += text.chars().count();
(pos, pos, Some(text.into()))
});