From 9dfadd6c784f725a9c5ec5929fde238b47800748 Mon Sep 17 00:00:00 2001 From: Aaron Muir Hamilton Date: Mon, 24 Oct 2022 21:30:36 +0000 Subject: [PATCH] Process Previous and Next by EGC rather than char. --- src/buffer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index f18e635..4ffad99 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -473,7 +473,7 @@ impl<'a> TextBuffer<'a> { if self.cursor.index > 0 { // Find previous character index let mut prev_index = 0; - for (i, _) in line.text.char_indices() { + for (i, _) in line.text.grapheme_indices(true) { if i < self.cursor.index { prev_index = i; } else { @@ -493,9 +493,9 @@ impl<'a> TextBuffer<'a> { let line = &mut self.lines[self.cursor.line.get()]; if self.cursor.index < line.text.len() { - for (i, c) in line.text.char_indices() { + for (i, c) in line.text.grapheme_indices(true) { if i == self.cursor.index { - self.cursor.index += c.len_utf8(); + self.cursor.index += c.len(); self.redraw = true; break; }