aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2022-10-09 17:37:57 +0200
committerJoris2022-10-09 17:37:57 +0200
commit9a5fe39f8ea1e2a88876c68a797ced28fbfd8457 (patch)
treeaf6b61aff884628aa5e193aa9ffc87a19cda1953 /src
parent3cf9a1ee7a14c711d11f57da13d70992767e2ffb (diff)
Let one space wher removing last word
Also fix the program to crash if there is no words.
Diffstat (limited to 'src')
-rw-r--r--src/gui/question.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/question.rs b/src/gui/question.rs
index 0d9d3c2..27759f8 100644
--- a/src/gui/question.rs
+++ b/src/gui/question.rs
@@ -150,8 +150,10 @@ pub fn ask<B: Backend>(
}
Key::Ctrl('w') => {
let mut words = state.input.split_whitespace().collect::<Vec<&str>>();
- words.truncate(words.len() - 1);
- state.input = words.join(" ");
+ if words.len() > 0 {
+ words.truncate(words.len() - 1);
+ state.input = format!("{}{}", words.join(" "), if words.len() > 0 {" " } else {""});
+ }
}
_ => {}
},