diff --git a/src/command_bar.rs b/src/command_bar.rs index bfcdf7f..7aa36ef 100644 --- a/src/command_bar.rs +++ b/src/command_bar.rs @@ -284,10 +284,30 @@ impl CommandBar { if self.command_line.chars().count() == 1 { self.show_hint(); } - self.command_line.pop(); - self.update_command_list(); + if self.command_line_idx > 0 { + self.update_command_list(); self.command_line_idx -= 1; + self.command_line = self + .command_line + .chars() + .enumerate() + .filter_map(|(i, c)| { + if i != self.command_line_idx { + Some(c) + } else { + None + } + }) + .collect(); + } + + if self.command_line.chars().count() > 0 + && self.command_line.chars().all(|x| x.is_whitespace()) + { + self.command_line.clear(); + self.command_line_idx = 0; + self.show_hint(); } } KeyCode::Right => {