on master help sign in
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.

commit4952d6f80154665b50f23d055a4f3bc0ab8ac330 authorNathan Vegdahl <cessen@cessen.com> dateMon 5 Jul 2021, 00:11 (5 years ago) parentfc34efe
1 file changed+10−5
helix-term/src/ui/editor.rs+10−5
helix-term/src/ui/editor.rs+10−5
@@ -8,7 +8,7 @@ use crate::{
88
99use helix_core::{
1010 coords_at_pos,
11− graphemes::ensure_grapheme_boundary,
11+ graphemes::{ensure_grapheme_boundary, next_grapheme_boundary},
1212 syntax::{self, HighlightEvent},
1313 LineEnding, Position, Range,
1414};
@@ -187,19 +187,24 @@ impl EditorView {
187187 (cursor_scope, selection_scope)
188188 };
189189
190+ let cursor_end = next_grapheme_boundary(text, range.head); // Used in every case below.
191+
190192 if range.head == range.anchor {
191− spans.push((cursor_scope, range.head..range.head + 1));
193+ spans.push((cursor_scope, range.head..cursor_end));
192194 continue;
193195 }
194196
195197 let reverse = range.head < range.anchor;
196198
197199 if reverse {
198− spans.push((cursor_scope, range.head..range.head + 1));
199− spans.push((selection_scope, range.head + 1..range.anchor + 1));
200+ spans.push((cursor_scope, range.head..cursor_end));
201+ spans.push((
202+ selection_scope,
203+ cursor_end..next_grapheme_boundary(text, range.anchor),
204+ ));
200205 } else {
201206 spans.push((selection_scope, range.anchor..range.head));
202− spans.push((cursor_scope, range.head..range.head + 1));
207+ spans.push((cursor_scope, range.head..cursor_end));
203208 }
204209 }
205210