Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
kirawi committed Jun 23, 2021
2 parents a8ac5b9 + 9706f11 commit a2a3f0f
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 129 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions helix-core/src/line_ending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion helix-core/src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub fn select_on_matches(

let start = text.byte_to_char(start_byte + mat.start());
let end = text.byte_to_char(start_byte + mat.end());
result.push(Range::new(start, end - 1));
result.push(Range::new(start, end.saturating_sub(1)));
}
}

Expand Down
Loading

0 comments on commit a2a3f0f

Please sign in to comment.