keep cursor inside value boundaries more reliable
This commit is contained in:
parent
767096b9bb
commit
731e6752eb
1 changed files with 3 additions and 3 deletions
|
|
@ -324,7 +324,7 @@ where
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
self.value.insert(self.state.cursor.end(), c);
|
self.value.insert(self.state.cursor.end().min(self.value.len()), c);
|
||||||
self.state.cursor.move_right(&self.value);
|
self.state.cursor.move_right(&self.value);
|
||||||
|
|
||||||
let message = (self.on_change)(self.value.to_string());
|
let message = (self.on_change)(self.value.to_string());
|
||||||
|
|
@ -347,11 +347,11 @@ where
|
||||||
self.state.cursor.move_left();
|
self.state.cursor.move_left();
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if self.state.cursor.start() > 0 {
|
if self.state.cursor.start().min(self.value.len()) > 0 {
|
||||||
self.state.cursor.move_left();
|
self.state.cursor.move_left();
|
||||||
let _ = self
|
let _ = self
|
||||||
.value
|
.value
|
||||||
.remove(self.state.cursor.start() - 1);
|
.remove(self.state.cursor.start());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue