From 3889cd833fa69a5336deea0677d9fcbc08665548 Mon Sep 17 00:00:00 2001 From: A-Walrus <58790821+A-Walrus@users.noreply.github.com> Date: Sat, 30 Jul 2022 20:17:01 +0300 Subject: [PATCH] Don't add empty prompt input to history (#3259) --- helix-term/src/ui/prompt.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 6e7df907e9775..03920a53af667 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -533,16 +533,17 @@ impl Component for Prompt { .map(|entry| entry.into()) .unwrap_or_else(|| Cow::from("")) } else { + if let Some(register) = self.history_register { + // store in history + let register = cx.editor.registers.get_mut(register); + register.push(self.line.clone()); + } + self.line.as_str().into() }; (self.callback_fn)(cx, &input, PromptEvent::Validate); - if let Some(register) = self.history_register { - // store in history - let register = cx.editor.registers.get_mut(register); - register.push(self.line.clone()); - } return close_fn; } }