diff options
author | Nathan Vegdahl | 2021-07-05 07:11:07 +0000 |
---|---|---|
committer | Ivan Tham | 2021-07-05 12:07:06 +0000 |
commit | 4952d6f80154665b50f23d055a4f3bc0ab8ac330 (patch) | |
tree | 8f606569490d1508bc2521a912aac84f4e3c7a4a /helix-term/src | |
parent | fc34efea124c23285770f9bd2e23dbcb905a6965 (diff) |
Fix phantom lines in some CRLF files.
Fixes #415. The issue was that cursor highlighting wasn't extending
to encompass the entire CRLF grapheme, and therefore ended up splitting
it. This presumably was messing up other grapheme rendering as
well, and this fixes that as well.
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/ui/editor.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index ad4f73bc..ef13004c 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -8,7 +8,7 @@ use crate::{ use helix_core::{ coords_at_pos, - graphemes::ensure_grapheme_boundary, + graphemes::{ensure_grapheme_boundary, next_grapheme_boundary}, syntax::{self, HighlightEvent}, LineEnding, Position, Range, }; @@ -187,19 +187,24 @@ impl EditorView { (cursor_scope, selection_scope) }; + let cursor_end = next_grapheme_boundary(text, range.head); // Used in every case below. + if range.head == range.anchor { - spans.push((cursor_scope, range.head..range.head + 1)); + spans.push((cursor_scope, range.head..cursor_end)); continue; } let reverse = range.head < range.anchor; if reverse { - spans.push((cursor_scope, range.head..range.head + 1)); - spans.push((selection_scope, range.head + 1..range.anchor + 1)); + spans.push((cursor_scope, range.head..cursor_end)); + spans.push(( + selection_scope, + cursor_end..next_grapheme_boundary(text, range.anchor), + )); } else { spans.push((selection_scope, range.anchor..range.head)); - spans.push((cursor_scope, range.head..range.head + 1)); + spans.push((cursor_scope, range.head..cursor_end)); } } |