Fix edge case in Editor::backspace

This commit is contained in:
Héctor Ramón Jiménez 2020-03-24 20:57:03 +01:00
parent 6c47a40730
commit 735d9f049c

View File

@ -47,8 +47,8 @@ impl<'a> Editor<'a> {
pub fn backspace(&mut self) {
match self.cursor.selection() {
Some((start, end)) => {
self.value.remove_many(start, end);
self.cursor.move_left(&self.value);
self.value.remove_many(start, end);
}
None => {
let start = self.cursor.start(&self.value);
@ -64,9 +64,8 @@ impl<'a> Editor<'a> {
pub fn delete(&mut self) {
match self.cursor.selection() {
Some((start, end)) => {
self.value.remove_many(start, end);
self.cursor.move_left(&self.value);
Some(_) => {
self.backspace();
}
None => {
let end = self.cursor.end(&self.value);