From 6d78b06405622ac5abc1b5587cc65d30a93e4815 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 30 Oct 2017 17:56:32 +1100 Subject: [PATCH] Do not auto apply the fallback regex when in regex prompts Fixes #1653 --- src/input_handler.cc | 3 ++- src/normal.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/input_handler.cc b/src/input_handler.cc index 794a9f5a..8f9e20f4 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -968,7 +968,8 @@ private: { display(); m_line_changed = false; - m_callback(m_line_editor.line(), PromptEvent::Change, context()); + m_callback((m_flags & PromptFlags::InactiveInitString) ? StringView{} : m_line_editor.line(), + PromptEvent::Change, context()); if (not (context().flags() & Context::Flags::Transient)) m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context())); diff --git a/src/normal.cc b/src/normal.cc index bd399dc9..50062632 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -718,7 +718,8 @@ void regex_prompt(Context& context, String prompt, String default_regex, T func) if (event == PromptEvent::Validate) context.push_jump(); - func(str.empty() ? Regex{default_regex} : Regex{str}, event, context); + if (not str.empty() or event == PromptEvent::Validate) + func(str.empty() ? Regex{default_regex} : Regex{str}, event, context); } catch (regex_error& err) {