From 38bf9c25761a9e56e1c4e4fe2894a205ecf7718d Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Tue, 22 Jun 2021 10:15:30 -0700 Subject: Missed some items in the CRLF PR. --- helix-core/src/line_ending.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'helix-core/src') 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::*; -- cgit v1.2.3-70-g09d2