diff options
author | Joris | 2022-10-09 17:37:57 +0200 |
---|---|---|
committer | Joris | 2022-10-09 17:37:57 +0200 |
commit | 9a5fe39f8ea1e2a88876c68a797ced28fbfd8457 (patch) | |
tree | af6b61aff884628aa5e193aa9ffc87a19cda1953 | |
parent | 3cf9a1ee7a14c711d11f57da13d70992767e2ffb (diff) |
Let one space wher removing last word
Also fix the program to crash if there is no words.
-rw-r--r-- | src/gui/question.rs | 6 |
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 {""}); + } } _ => {} }, |