diff options
author | Wojciech Kępka | 2021-06-08 06:25:55 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-08 08:22:37 +0000 |
commit | 48df05b16dba362366b63284c2e551c51995fb66 (patch) | |
tree | 9f8d6442c74c50c46ac7ad1979fea8a3fa0bb731 /helix-core/src/lib.rs | |
parent | b873fb9897bb5b24a60cca3d9fa69285446a857f (diff) |
commands: Add goto first non-whitespace char of line
Diffstat (limited to 'helix-core/src/lib.rs')
-rw-r--r-- | helix-core/src/lib.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs index cfe466ed..da48ba7e 100644 --- a/helix-core/src/lib.rs +++ b/helix-core/src/lib.rs @@ -18,16 +18,8 @@ pub mod syntax; mod transaction; pub mod words; -pub(crate) fn find_first_non_whitespace_char2(line: RopeSlice) -> Option<usize> { - // find first non-whitespace char - for (start, ch) in line.chars().enumerate() { - // TODO: could use memchr with chunks? - if ch != ' ' && ch != '\t' && ch != '\n' { - return Some(start); - } - } - - None +pub fn find_first_non_whitespace_char2(line: RopeSlice) -> Option<usize> { + line.chars().position(|ch| !ch.is_whitespace()) } pub(crate) fn find_first_non_whitespace_char(text: RopeSlice, line_num: usize) -> Option<usize> { let line = text.line(line_num); |