@@ -8,6 +8,7 @@ use crate::{
9use helix_core::{
9use helix_core::{
10 coords_at_pos,
10 coords_at_pos,
11+ graphemes::{ensure_grapheme_boundary, ensure_grapheme_boundary_byte},
11 syntax::{self, HighlightEvent},
12 syntax::{self, HighlightEvent},
12 LineEnding, Position, Range,
13 LineEnding, Position, Range,
@@ -141,7 +142,8 @@ impl EditorView {
142 'outer: for event in highlights {
143 'outer: for event in highlights {
143 match event.unwrap() {
144 match event.unwrap() {
144− HighlightEvent::HighlightStart(span) => {
145+ HighlightEvent::HighlightStart(mut span) => {
146+ span.0 = ensure_grapheme_boundary_byte(text, span.0);
145 spans.push(span);
147 spans.push(span);
147 HighlightEvent::HighlightEnd => {
149 HighlightEvent::HighlightEnd => {
@@ -151,8 +153,8 @@ impl EditorView {
151 // TODO: filter out spans out of viewport for now..
153 // TODO: filter out spans out of viewport for now..
153 // TODO: do these before iterating
155 // TODO: do these before iterating
154− let start = text.byte_to_char(start);
156+ let start = ensure_grapheme_boundary(text, text.byte_to_char(start));
155− let end = text.byte_to_char(end);
157+ let end = ensure_grapheme_boundary(text, text.byte_to_char(end));
157 let text = text.slice(start..end);
159 let text = text.slice(start..end);