From 35f23d6fad77e3799fda33e70435f3f3593e79f1 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 3 Dec 2022 19:00:46 +0100 Subject: [PATCH] Remove bogus assertions preventing mouse clicks in insert mode Recent changes for selection-undo added an assertion that triggers when a mouse-drag overlaps with an insert mode, because both events record selection history. However this is actually fine. The one that finishes last concludes the selection edition, while the other one will be a nop. The test could be simpler (i.e. not require sleeps) but I figured it doesn't hurt add this since we don't have any comparable tests. --- src/context.hh | 1 - src/input_handler.cc | 2 -- test/regression/0-mouse-during-insert/cmd | 1 + test/regression/0-mouse-during-insert/in | 1 + test/regression/0-mouse-during-insert/out | 1 + test/regression/0-mouse-during-insert/script | 11 +++++++++++ 6 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 test/regression/0-mouse-during-insert/cmd create mode 100644 test/regression/0-mouse-during-insert/in create mode 100644 test/regression/0-mouse-during-insert/out create mode 100644 test/regression/0-mouse-during-insert/script diff --git a/src/context.hh b/src/context.hh index 5ef3c42c1..3fe28dc2d 100644 --- a/src/context.hh +++ b/src/context.hh @@ -117,7 +117,6 @@ public: bool is_editing() const { return m_edition_level!= 0; } void disable_undo_handling() { m_edition_level = -1; } - bool is_editing_selection() const { return m_selection_history.in_edition(); } NestedBool& hooks_disabled() { return m_hooks_disabled; } const NestedBool& hooks_disabled() const { return m_hooks_disabled; } diff --git a/src/input_handler.cc b/src/input_handler.cc index f90d2d225..664490d6a 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -100,7 +100,6 @@ struct MouseHandler switch (key.mouse_button()) { case Key::MouseButton::Right: { - kak_assert(not context.is_editing_selection()); m_dragging.reset(); cursor = context.window().buffer_coord(key.coord()); ScopedSelectionEdition selection_edition{context}; @@ -114,7 +113,6 @@ struct MouseHandler } case Key::MouseButton::Left: { - kak_assert(not context.is_editing_selection()); m_dragging.reset(new ScopedSelectionEdition{context}); m_anchor = context.window().buffer_coord(key.coord()); if (not (key.modifiers & Key::Modifiers::Control)) diff --git a/test/regression/0-mouse-during-insert/cmd b/test/regression/0-mouse-during-insert/cmd new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/test/regression/0-mouse-during-insert/cmd @@ -0,0 +1 @@ + diff --git a/test/regression/0-mouse-during-insert/in b/test/regression/0-mouse-during-insert/in new file mode 100644 index 000000000..190a18037 --- /dev/null +++ b/test/regression/0-mouse-during-insert/in @@ -0,0 +1 @@ +123 diff --git a/test/regression/0-mouse-during-insert/out b/test/regression/0-mouse-during-insert/out new file mode 100644 index 000000000..547b8306b --- /dev/null +++ b/test/regression/0-mouse-during-insert/out @@ -0,0 +1 @@ +a1b2c3 diff --git a/test/regression/0-mouse-during-insert/script b/test/regression/0-mouse-during-insert/script new file mode 100644 index 000000000..aaf225ce4 --- /dev/null +++ b/test/regression/0-mouse-during-insert/script @@ -0,0 +1,11 @@ +ui_out -ignore 4 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "i" ] }' +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "a" ] }' +sleep .1 +ui_in '{ "jsonrpc": "2.0", "method": "mouse_press", "params": [ "left", 0, 2 ] }' +sleep .1 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "b" ] }' +sleep .1 +ui_in '{ "jsonrpc": "2.0", "method": "mouse_release", "params": [ "left", 0, 4 ] }' +sleep .1 +ui_in '{ "jsonrpc": "2.0", "method": "keys", "params": [ "c" ] }'