Fix partial regex text being pushed in history

This commit is contained in:
Maxime Coste 2023-11-02 13:00:12 +11:00
parent 8cc4de5bb3
commit a2c41593aa
5 changed files with 19 additions and 12 deletions

View File

@ -853,23 +853,22 @@ void regex_prompt(Context& context, String prompt, char reg, T func)
context.window().set_position(position);
context.input_handler().set_prompt_face(context.faces()["Prompt"]);
RegisterManager::instance()[reg].restore(context, saved_reg);
}
switch (event)
{
case PromptEvent::Abort: return;
case PromptEvent::Change:
if (not incsearch or str.empty())
return;
if (incsearch and not str.empty())
RegisterManager::instance()[reg].set(context, str.str());
func(Regex{str, direction_flags(mode)}, event, context);
return;
case PromptEvent::Abort:
RegisterManager::instance()[reg].restore(context, saved_reg);
return;
break;
case PromptEvent::Validate:
RegisterManager::instance()[reg].set(context, str.str());
context.push_jump();
func(Regex{str.empty() ? default_regex : str, direction_flags(mode)}, event, context);
return;
break;
}
func(Regex{str.empty() ? default_regex : str, direction_flags(mode)}, event, context);
}
catch (regex_error& err)
{

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
foo bar

View File

@ -0,0 +1,5 @@
ui_out -ignore 4
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "/foo<ret>/b" ] }'
sleep 0.1
ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "ar<ret>/<up><up><ret>" ] }'
ui_out -ignore 1