Fix panic in kill_to_end_of_line when handling multibyte characters (#12237)

This commit is contained in:
Takumi Matsuura 2024-12-14 05:04:52 +09:00 committed by GitHub
parent 617f538d41
commit e14c346ee7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -233,15 +233,7 @@ fn eval_movement(&self, movement: Movement) -> usize {
position
}
Movement::StartOfLine => 0,
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::EndOfLine => self.line.len(),
Movement::None => self.cursor,
}
}