From 58f46fed19f3d8a87e27c5b3ba3bc363fbbbdc29 Mon Sep 17 00:00:00 2001 From: Canop Date: Sun, 7 Nov 2021 07:47:49 +0100 Subject: consider an input containing only spaces as empty on enter Previously, when typing a space to start a verb, not typing it, then typing enter to open, a 'verb "" not found' message was displayed. Now the space is just ignored. --- src/command/panel_input.rs | 2 +- src/command/parts.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/command/panel_input.rs b/src/command/panel_input.rs index 419447b..879b7fb 100644 --- a/src/command/panel_input.rs +++ b/src/command/panel_input.rs @@ -298,7 +298,7 @@ impl PanelInput { self.input_before_cycle = None; } - if key == keys::ENTER && parts.verb_invocation.is_some() { + if key == keys::ENTER && parts.has_not_empty_verb_invocation() { return Command::from_parts(parts, true); } diff --git a/src/command/parts.rs b/src/command/parts.rs index a82e3ad..b355de5 100644 --- a/src/command/parts.rs +++ b/src/command/parts.rs @@ -26,6 +26,11 @@ impl fmt::Display for CommandParts { } impl CommandParts { + pub fn has_not_empty_verb_invocation(&self) -> bool { + self.verb_invocation + .as_ref() + .map_or(false, |vi| !vi.is_empty()) + } pub fn from(mut raw: String) -> Self { let mut invocation_start_pos: Option = None; let mut escaping = false; -- cgit v1.2.3