aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/line_ending.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-06 01:58:33 +0000
committerNathan Vegdahl2021-07-06 01:58:33 +0000
commit6e15c9b8745e9708ee5271c8701d41a8393cb038 (patch)
tree1d82bb2320020d6a6a2b893db69e5bc9f3e5256d /helix-core/src/line_ending.rs
parent28d2d6880462509f0d3131eb2eb928bb8859e058 (diff)
Make vertical selection movement work properly.
Diffstat (limited to 'helix-core/src/line_ending.rs')
-rw-r--r--helix-core/src/line_ending.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/helix-core/src/line_ending.rs b/helix-core/src/line_ending.rs
index e3ff6478..18ea5f9f 100644
--- a/helix-core/src/line_ending.rs
+++ b/helix-core/src/line_ending.rs
@@ -159,6 +159,13 @@ pub fn line_end_char_index(slice: &RopeSlice, line: usize) -> usize {
.unwrap_or(0)
}
+/// Fetches line `line_idx` from the passed rope slice, sans any line ending.
+pub fn line_without_line_ending<'a>(slice: &'a RopeSlice, line_idx: usize) -> RopeSlice<'a> {
+ let start = slice.line_to_char(line_idx);
+ let end = line_end_char_index(slice, line_idx);
+ slice.slice(start..end)
+}
+
/// 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 {