From 641acc59433f73e6bc64f9d04e98deae7d7c5ffc Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 27 Jun 2017 09:57:10 +0100 Subject: [PATCH] Do not allow repeating last insert when we are not in normal mode . is not accepted anymore. Note that are not repeatable currently anyway (That could be fixed, athough not trivial). Fixes #1469 --- src/input_handler.cc | 3 +++ test/regression/1469-assert-on-repeat-insert/cmd | 1 + test/regression/1469-assert-on-repeat-insert/in | 1 + test/regression/1469-assert-on-repeat-insert/out | 2 ++ test/regression/787-crash-after-S/out | 1 + test/run | 2 +- 6 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/regression/1469-assert-on-repeat-insert/cmd create mode 100644 test/regression/1469-assert-on-repeat-insert/in create mode 100644 test/regression/1469-assert-on-repeat-insert/out diff --git a/src/input_handler.cc b/src/input_handler.cc index 217f3a5c..2a14fc71 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1430,6 +1430,9 @@ void InputHandler::repeat_last_insert() if (m_last_insert.keys.empty()) return; + if (dynamic_cast(¤t_mode()) == nullptr) + throw runtime_error{"repeating last insert not available in this context"}; + Vector keys; swap(keys, m_last_insert.keys); ScopedSetBool disable_hooks(context().hooks_disabled(), diff --git a/test/regression/1469-assert-on-repeat-insert/cmd b/test/regression/1469-assert-on-repeat-insert/cmd new file mode 100644 index 00000000..44f1421d --- /dev/null +++ b/test/regression/1469-assert-on-repeat-insert/cmd @@ -0,0 +1 @@ +i!echo tchou. diff --git a/test/regression/1469-assert-on-repeat-insert/in b/test/regression/1469-assert-on-repeat-insert/in new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/1469-assert-on-repeat-insert/in @@ -0,0 +1 @@ + diff --git a/test/regression/1469-assert-on-repeat-insert/out b/test/regression/1469-assert-on-repeat-insert/out new file mode 100644 index 00000000..89bd8679 --- /dev/null +++ b/test/regression/1469-assert-on-repeat-insert/out @@ -0,0 +1,2 @@ +tchou + diff --git a/test/regression/787-crash-after-S/out b/test/regression/787-crash-after-S/out index e69de29b..8b137891 100644 --- a/test/regression/787-crash-after-S/out +++ b/test/regression/787-crash-after-S/out @@ -0,0 +1 @@ + diff --git a/test/run b/test/run index 2d0e3d86..a9d35d41 100755 --- a/test/run +++ b/test/run @@ -19,7 +19,7 @@ main() { eval -buffer *debug* write debug quit! } - exec "%sh{cat cmd}" + try %{ exec "%sh{cat cmd}" } exec eval -buffer *debug* write debug nop %sh{