This commit is contained in:
veeso
2021-03-26 22:19:24 +01:00
parent de3983e53f
commit 423f84353d
8 changed files with 34 additions and 45 deletions

View File

@@ -86,7 +86,7 @@ impl OwnStates {
///
/// Delete element at cursor -1; then decrement cursor by 1
pub fn backspace(&mut self) {
if self.cursor > 0 && self.input.len() > 0 {
if self.cursor > 0 && !self.input.is_empty() {
self.input.remove(self.cursor - 1);
// Decrement cursor
self.cursor -= 1;
@@ -106,7 +106,7 @@ impl OwnStates {
///
/// Increment cursor value by one if possible
pub fn incr_cursor(&mut self) {
if self.cursor + 1 <= self.input.len() {
if self.cursor < self.input.len() {
self.cursor += 1;
}
}

View File

@@ -79,7 +79,7 @@ impl OwnStates {
/// ### make_choices
///
/// Set OwnStates choices from a vector of text spans
pub fn make_choices(&mut self, spans: &Vec<TextSpan>) {
pub fn make_choices(&mut self, spans: &[TextSpan]) {
self.choices = spans.iter().map(|x| x.content.clone()).collect();
}
}