From 2dba228c766e5e9e4b0fe0c12d30909f51faa28e Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Fri, 25 Jun 2021 10:13:51 -0700 Subject: Fix highlight code splitting graphemes. This resulted in phantom blank lines in files with CRLF line endings, but could potentially have manifested with other graphemes as well. --- helix-term/src/ui/editor.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'helix-term/src/ui') diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 93f000e7..14cfc7dd 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -8,6 +8,7 @@ use crate::{ use helix_core::{ coords_at_pos, + graphemes::{ensure_grapheme_boundary, ensure_grapheme_boundary_byte}, syntax::{self, HighlightEvent}, LineEnding, Position, Range, }; @@ -141,7 +142,8 @@ impl EditorView { 'outer: for event in highlights { match event.unwrap() { - HighlightEvent::HighlightStart(span) => { + HighlightEvent::HighlightStart(mut span) => { + span.0 = ensure_grapheme_boundary_byte(text, span.0); spans.push(span); } HighlightEvent::HighlightEnd => { @@ -151,8 +153,8 @@ impl EditorView { // TODO: filter out spans out of viewport for now.. // TODO: do these before iterating - let start = text.byte_to_char(start); - let end = text.byte_to_char(end); + let start = ensure_grapheme_boundary(text, text.byte_to_char(start)); + let end = ensure_grapheme_boundary(text, text.byte_to_char(end)); let text = text.slice(start..end); -- cgit v1.2.3-70-g09d2