aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/line_ending.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-06-22 17:15:30 +0000
committerBlaž Hrastnik2021-06-23 03:43:09 +0000
commit38bf9c25761a9e56e1c4e4fe2894a205ecf7718d (patch)
tree206cba6061960b96a79d55a1d1292c2aa4ed1d69 /helix-core/src/line_ending.rs
parent9c53461429a3e72e3b1fb87d7ca490e168d7dee2 (diff)
Missed some items in the CRLF PR.
Diffstat (limited to 'helix-core/src/line_ending.rs')
-rw-r--r--helix-core/src/line_ending.rs6
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::*;