From 7833b53272d89da92d7a24bd5726cf16b3e90bbf Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 13 Apr 2016 21:21:49 +0100 Subject: [PATCH] Fix support for macro being recorded and replay during :exec (non draft) --- src/input_handler.cc | 11 ++++++++++- src/input_handler.hh | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/input_handler.cc b/src/input_handler.cc index e674790f..7732f336 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1395,14 +1395,22 @@ void InputHandler::handle_key(Key key) // do not record the key that made us enter or leave recording mode, // and the ones that are triggered recursively by previous keys. - if (was_recording and is_recording() and m_handle_key_level == 1) + if (was_recording and is_recording() and m_handle_key_level == m_recording_level) m_recorded_keys += key_to_str(key); + + if (m_handle_key_level < m_recording_level) + { + write_to_debug_buffer("Macro recording started but not finished"); + m_recording_reg = 0; + m_handle_key_level = -1; + } } } void InputHandler::start_recording(char reg) { kak_assert(m_recording_reg == 0); + m_recording_level = m_handle_key_level; m_recorded_keys = ""; m_recording_reg = reg; } @@ -1417,6 +1425,7 @@ void InputHandler::stop_recording() kak_assert(m_recording_reg != 0); RegisterManager::instance()[m_recording_reg] = ConstArrayView(m_recorded_keys); m_recording_reg = 0; + m_recording_level = -1; } DisplayLine InputHandler::mode_line() const diff --git a/src/input_handler.hh b/src/input_handler.hh index 41397b28..77153c2d 100644 --- a/src/input_handler.hh +++ b/src/input_handler.hh @@ -109,6 +109,7 @@ private: char m_recording_reg = 0; String m_recorded_keys; + int m_recording_level = -1; int m_handle_key_level = 0; };