From 9a5fe39f8ea1e2a88876c68a797ced28fbfd8457 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 9 Oct 2022 17:37:57 +0200 Subject: Let one space wher removing last word Also fix the program to crash if there is no words. --- src/gui/question.rs | 6 ++++-- 1 file 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( } Key::Ctrl('w') => { let mut words = state.input.split_whitespace().collect::>(); - 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 {""}); + } } _ => {} }, -- cgit v1.2.3