From 9d8c9777a46a37818a6c4a336f0ff5c4d79f5f18 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 13 Jan 2024 14:18:18 +0100 Subject: [PATCH 1/2] Await all UI events after each key press in mouse-during-insert test This test doesn't care about testing things like "if I send the next key before we have finished reacting to the previous ones, nothing bad ever happens". Hence we can until exhaustion after each input. This should fix bespoke flakiness. The handling of "c" should be atomic. This reasoning probably applies to most tests; waiting for all events seems like the safest and easiest approach overall (compared to sleep or sleep-until). The downside is that the tests need changes when UI code changes but it rarely does, and if it does we can automate the updates. Closes #5073 --- test/regression/0-mouse-during-insert/script | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/regression/0-mouse-during-insert/script b/test/regression/0-mouse-during-insert/script index c85d78d6..439d70d3 100644 --- a/test/regression/0-mouse-during-insert/script +++ b/test/regression/0-mouse-during-insert/script @@ -1,10 +1,13 @@ ui_out -ignore 7 ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "i" ] }' +ui_out -ignore 4 ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "a" ] }' -ui_out -ignore 8 +ui_out -ignore 4 ui_in '{ "jsonrpc": "2.0", "method": "mouse_press", "params": [ "left", 0, 2 ] }' +ui_out -ignore 4 ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "b" ] }' -ui_out -ignore 8 +ui_out -ignore 4 ui_in '{ "jsonrpc": "2.0", "method": "mouse_release", "params": [ "left", 0, 4 ] }' +ui_out -ignore 4 ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "c" ] }' -ui_out -ignore 1 +ui_out -ignore 4 From 20b0eadfc8f9e6ead962bb0230b8ebfe32d8a2fa Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 13 Jan 2024 16:52:55 +0100 Subject: [PATCH 2/2] Don't modify prompt history when validating empty input Fixes #5076 --- src/normal.cc | 3 ++- .../5076-empty-text-should-not-change-prompt-history/cmd | 1 + .../5076-empty-text-should-not-change-prompt-history/in | 1 + .../kak_selections | 1 + .../script | 7 +++++++ 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test/regression/5076-empty-text-should-not-change-prompt-history/cmd create mode 100644 test/regression/5076-empty-text-should-not-change-prompt-history/in create mode 100644 test/regression/5076-empty-text-should-not-change-prompt-history/kak_selections create mode 100644 test/regression/5076-empty-text-should-not-change-prompt-history/script diff --git a/src/normal.cc b/src/normal.cc index 019ed58a..03e7895c 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -866,7 +866,8 @@ void regex_prompt(Context& context, String prompt, char reg, T func) RegisterManager::instance()[reg].set(context, str.str()); break; case PromptEvent::Validate: - RegisterManager::instance()[reg].set(context, str.str()); + if (not str.empty()) + RegisterManager::instance()[reg].set(context, str.str()); context.push_jump(); break; } diff --git a/test/regression/5076-empty-text-should-not-change-prompt-history/cmd b/test/regression/5076-empty-text-should-not-change-prompt-history/cmd new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/5076-empty-text-should-not-change-prompt-history/cmd @@ -0,0 +1 @@ + diff --git a/test/regression/5076-empty-text-should-not-change-prompt-history/in b/test/regression/5076-empty-text-should-not-change-prompt-history/in new file mode 100644 index 00000000..1790c8d8 --- /dev/null +++ b/test/regression/5076-empty-text-should-not-change-prompt-history/in @@ -0,0 +1 @@ +abab diff --git a/test/regression/5076-empty-text-should-not-change-prompt-history/kak_selections b/test/regression/5076-empty-text-should-not-change-prompt-history/kak_selections new file mode 100644 index 00000000..a4c6917f --- /dev/null +++ b/test/regression/5076-empty-text-should-not-change-prompt-history/kak_selections @@ -0,0 +1 @@ +a a diff --git a/test/regression/5076-empty-text-should-not-change-prompt-history/script b/test/regression/5076-empty-text-should-not-change-prompt-history/script new file mode 100644 index 00000000..8c2457f1 --- /dev/null +++ b/test/regression/5076-empty-text-should-not-change-prompt-history/script @@ -0,0 +1,7 @@ +ui_out -ignore 7 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "xsa" ] }' +ui_out -ignore 6 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "xs" ] }' +ui_out -ignore 5 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "xs" ] }' +ui_out -ignore 5