aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src')
-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::*;