diff options
author | Blaž Hrastnik | 2021-02-18 09:34:22 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-02-18 09:34:22 +0000 |
commit | c9dd1c930edee68a32ef19ee407820c247937b05 (patch) | |
tree | 667de4906e291df3b1dc1e6f71460415e4eb2501 /helix-core/src/lib.rs | |
parent | bd85460698c8d74f1a7b79c286a627c3ffcfb67e (diff) |
treewide: &RopeSlice -> RopeSlice. It's Copy so no reason to pass by ref
Diffstat (limited to 'helix-core/src/lib.rs')
-rw-r--r-- | helix-core/src/lib.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs index ddf1439c..f9fe4bd4 100644 --- a/helix-core/src/lib.rs +++ b/helix-core/src/lib.rs @@ -11,6 +11,36 @@ pub mod state; pub mod syntax; mod transaction; +pub(crate) fn find_first_non_whitespace_char2(line: RopeSlice) -> Option<usize> { + let mut start = 0; + + // find first non-whitespace char + for ch in line.chars() { + // TODO: could use memchr with chunks? + if ch != ' ' && ch != '\t' && ch != '\n' { + return Some(start); + } + start += 1; + } + + None +} +pub(crate) fn find_first_non_whitespace_char(text: RopeSlice, line_num: usize) -> Option<usize> { + let line = text.line(line_num); + let mut start = text.line_to_char(line_num); + + // find first non-whitespace char + for ch in line.chars() { + // TODO: could use memchr with chunks? + if ch != ' ' && ch != '\t' && ch != '\n' { + return Some(start); + } + start += 1; + } + + None +} + pub use ropey::{Rope, RopeSlice}; pub use tendril::StrTendril as Tendril; |