From a45876124b0f0abad828f81c9406b37e0c2dc622 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 4 Sep 2015 19:00:42 +0100 Subject: [PATCH] Avoid restoring selections in regex_prompt when they cannot have been modified --- src/normal.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index 5a6eda2a..ff57d614 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -563,16 +563,20 @@ void regex_prompt(Context& context, const String prompt, T func) { if (event != PromptEvent::Change and context.has_ui()) context.ui().info_hide(); - selections.update(); - context.selections_write_only() = selections; - if (context.has_window()) - context.window().set_position(position); - context.input_handler().set_prompt_face(get_face("Prompt")); - if (event == PromptEvent::Abort) - return; - if (event == PromptEvent::Change and - (str.empty() or not context.options()["incsearch"].get())) + const bool incsearch = context.options()["incsearch"].get(); + if (incsearch) + { + selections.update(); + context.selections_write_only() = selections; + if (context.has_window()) + context.window().set_position(position); + + context.input_handler().set_prompt_face(get_face("Prompt")); + } + + if (event == PromptEvent::Abort or + (event == PromptEvent::Change and (not incsearch or str.empty()))) return; if (event == PromptEvent::Validate)