aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorNathan Vegdahl2021-06-25 17:13:51 +0000
committerBlaž Hrastnik2021-06-26 02:09:50 +0000
commit2dba228c766e5e9e4b0fe0c12d30909f51faa28e (patch)
tree64c2fde5df50cd2266c3b1d99a305593af9770de /helix-term
parenteb6fb63e748bc465996cec8b07241590c4bab68b (diff)
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.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs8
1 files changed, 5 insertions, 3 deletions
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);