@@ -8,6 +8,7 @@ use crate::{
88
99use helix_core::{
1010 coords_at_pos,
11+ graphemes::{ensure_grapheme_boundary, ensure_grapheme_boundary_byte},
1112 syntax::{self, HighlightEvent},
1213 LineEnding, Position, Range,
1314};
@@ -141,7 +142,8 @@ impl EditorView {
141142
142143 'outer: for event in highlights {
143144 match event.unwrap() {
144− HighlightEvent::HighlightStart(span) => {
145+ HighlightEvent::HighlightStart(mut span) => {
146+ span.0 = ensure_grapheme_boundary_byte(text, span.0);
145147 spans.push(span);
146148 }
147149 HighlightEvent::HighlightEnd => {
@@ -151,8 +153,8 @@ impl EditorView {
151153 // TODO: filter out spans out of viewport for now..
152154
153155 // TODO: do these before iterating
154− let start = text.byte_to_char(start);
155− let end = text.byte_to_char(end);
156+ let start = ensure_grapheme_boundary(text, text.byte_to_char(start));
157+ let end = ensure_grapheme_boundary(text, text.byte_to_char(end));
156158
157159 let text = text.slice(start..end);
158160