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.rs5
-rw-r--r--helix-core/src/movement.rs6
2 files changed, 6 insertions, 5 deletions
diff --git a/helix-core/src/line_ending.rs b/helix-core/src/line_ending.rs
index 2cc5b5d8..33f8d078 100644
--- a/helix-core/src/line_ending.rs
+++ b/helix-core/src/line_ending.rs
@@ -38,9 +38,8 @@ impl LineEnding {
pub fn rope_slice_to_line_ending(g: &RopeSlice) -> Option<LineEnding> {
if let Some(text) = g.as_str() {
str_to_line_ending(text)
- } else if g == "\u{000D}\u{000A}" {
- Some(LineEnding::Crlf)
- } else {
+ }
+ else {
// Not a line ending
None
}
diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs
index 8b1e802f..cf7ea854 100644
--- a/helix-core/src/movement.rs
+++ b/helix-core/src/movement.rs
@@ -5,7 +5,7 @@ use ropey::iter::Chars;
use crate::{
coords_at_pos,
graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary},
- pos_at_coords, Position, Range, RopeSlice,
+ pos_at_coords, Position, Range, RopeSlice, get_line_ending
};
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@@ -38,7 +38,9 @@ pub fn move_horizontally(
}
Direction::Forward => {
// Line end is pos at the start of next line - 1
- let end = slice.line_to_char(line + 1).saturating_sub(1);
+ let end = slice.line_to_char(line + 1).saturating_sub(get_line_ending(&slice.line(line))
+ .map(|le| le.len_chars())
+ .unwrap_or(0));
nth_next_grapheme_boundary(slice, pos, count).min(end)
}
};