From 48df05b16dba362366b63284c2e551c51995fb66 Mon Sep 17 00:00:00 2001 From: Wojciech Kępka Date: Tue, 8 Jun 2021 08:25:55 +0200 Subject: commands: Add goto first non-whitespace char of line --- helix-core/src/lib.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'helix-core/src/lib.rs') 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 { - // 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 { + line.chars().position(|ch| !ch.is_whitespace()) } pub(crate) fn find_first_non_whitespace_char(text: RopeSlice, line_num: usize) -> Option { let line = text.line(line_num); -- cgit v1.2.3-70-g09d2