diff options
author | Jan Hrastnik | 2021-06-19 23:24:36 +0000 |
---|---|---|
committer | Jan Hrastnik | 2021-06-19 23:24:36 +0000 |
commit | 701eb0dd6800e75116f36e503787dd0f50df709e (patch) | |
tree | 0f17888a021104cdc8055047fe0b17077b09ef65 /helix-core | |
parent | 1e80fbb6020c75bdc5d7e3edc9513b4ed52c4e6b (diff) |
changed some hardcoded newlines, removed a else if in line_ending.rs
Diffstat (limited to 'helix-core')
-rw-r--r-- | helix-core/src/line_ending.rs | 5 | ||||
-rw-r--r-- | helix-core/src/movement.rs | 6 |
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) } }; |