diff options
author | Nathan Vegdahl | 2021-06-22 17:15:30 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-23 03:43:09 +0000 |
commit | 38bf9c25761a9e56e1c4e4fe2894a205ecf7718d (patch) | |
tree | 206cba6061960b96a79d55a1d1292c2aa4ed1d69 /helix-core | |
parent | 9c53461429a3e72e3b1fb87d7ca490e168d7dee2 (diff) |
Missed some items in the CRLF PR.
Diffstat (limited to 'helix-core')
-rw-r--r-- | helix-core/src/line_ending.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/helix-core/src/line_ending.rs b/helix-core/src/line_ending.rs index fa33204c..7ea3f14a 100644 --- a/helix-core/src/line_ending.rs +++ b/helix-core/src/line_ending.rs @@ -159,6 +159,12 @@ pub fn line_end_char_index(slice: &RopeSlice, line: usize) -> usize { .unwrap_or(0) } +/// Returns the char index of the end of the given RopeSlice, not including +/// any final line ending. +pub fn rope_end_without_line_ending(slice: &RopeSlice) -> usize { + slice.len_chars() - get_line_ending(slice).map(|le| le.len_chars()).unwrap_or(0) +} + #[cfg(test)] mod line_ending_tests { use super::*; |