Remove redundant min checks in Editor

This commit is contained in:
Héctor Ramón Jiménez 2020-07-11 00:11:45 +02:00
parent a1210c9dae
commit 4314ce36f4

View file

@ -18,7 +18,7 @@ impl<'a> Editor<'a> {
match self.cursor.selection(self.value) { match self.cursor.selection(self.value) {
Some((left, right)) => { Some((left, right)) => {
self.cursor.move_left(self.value); self.cursor.move_left(self.value);
self.value.remove_many(left, right.min(self.value.len())); self.value.remove_many(left, right);
} }
_ => (), _ => (),
} }
@ -33,7 +33,7 @@ impl<'a> Editor<'a> {
match self.cursor.selection(self.value) { match self.cursor.selection(self.value) {
Some((left, right)) => { Some((left, right)) => {
self.cursor.move_left(self.value); self.cursor.move_left(self.value);
self.value.remove_many(left, right.min(self.value.len())); self.value.remove_many(left, right);
} }
_ => (), _ => (),
} }
@ -47,7 +47,7 @@ impl<'a> Editor<'a> {
match self.cursor.selection(self.value) { match self.cursor.selection(self.value) {
Some((start, end)) => { Some((start, end)) => {
self.cursor.move_left(self.value); self.cursor.move_left(self.value);
self.value.remove_many(start, end.min(self.value.len())); self.value.remove_many(start, end);
} }
None => { None => {
let start = self.cursor.start(self.value); let start = self.cursor.start(self.value);