on master help sign in
Fix phantom lines in some CRLF files.
4952d6fNathan Vegdahl
helix-term/src/ui/editor.rs+10−5
@@ -8,7 +8,7 @@ use crate::{
8
8
9use helix_core::{
9use helix_core::{
10 coords_at_pos,
10 coords_at_pos,
11− graphemes::ensure_grapheme_boundary,
11+ graphemes::{ensure_grapheme_boundary, next_grapheme_boundary},
12 syntax::{self, HighlightEvent},
12 syntax::{self, HighlightEvent},
13 LineEnding, Position, Range,
13 LineEnding, Position, Range,
14};
14};
@@ -187,19 +187,24 @@ impl EditorView {
187 (cursor_scope, selection_scope)
187 (cursor_scope, selection_scope)
188 };
188 };
189
189
190+ let cursor_end = next_grapheme_boundary(text, range.head); // Used in every case below.
191+
190 if range.head == range.anchor {
192 if range.head == range.anchor {
191− spans.push((cursor_scope, range.head..range.head + 1));
193+ spans.push((cursor_scope, range.head..cursor_end));
192 continue;
194 continue;
193 }
195 }
194
196
195 let reverse = range.head < range.anchor;
197 let reverse = range.head < range.anchor;
196
198
197 if reverse {
199 if reverse {
198− spans.push((cursor_scope, range.head..range.head + 1));
200+ spans.push((cursor_scope, range.head..cursor_end));
201+ spans.push((
199− spans.push((selection_scope, range.head + 1..range.anchor + 1));
202+ selection_scope,
203+ cursor_end..next_grapheme_boundary(text, range.anchor),
204+ ));
200 } else {
205 } else {
201 spans.push((selection_scope, range.anchor..range.head));
206 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));
203 }
208 }
204 }
209 }
205
210