diff options
author | Canop <cano.petrole@gmail.com> | 2021-11-07 07:47:49 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-11-07 07:47:49 +0100 |
commit | 58f46fed19f3d8a87e27c5b3ba3bc363fbbbdc29 (patch) | |
tree | 6d39d06a5b1c202e38a2b5906e65f71d93924d20 /src/command | |
parent | 335c2847d57ad8b89141da9060fe11524f29b9f4 (diff) |
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.
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/panel_input.rs | 2 | ||||
-rw-r--r-- | src/command/parts.rs | 5 |
2 files changed, 6 insertions, 1 deletions
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<usize> = None; let mut escaping = false; |