diff --git a/termwiz/src/lineedit/buffer.rs b/termwiz/src/lineedit/buffer.rs index 97dbdca5f1c..1d922d1a227 100644 --- a/termwiz/src/lineedit/buffer.rs +++ b/termwiz/src/lineedit/buffer.rs @@ -174,7 +174,15 @@ impl LineEditBuffer { position } Movement::StartOfLine => 0, - Movement::EndOfLine => self.line.len(), + Movement::EndOfLine => { + let mut cursor = + GraphemeCursor::new(self.line.len().saturating_sub(1), self.line.len(), false); + if let Ok(Some(pos)) = cursor.next_boundary(&self.line, 0) { + pos + } else { + self.cursor + } + } Movement::None => self.cursor, } }