diff --git a/src/main.cc b/src/main.cc index 25195303d..1d848f430 100644 --- a/src/main.cc +++ b/src/main.cc @@ -798,6 +798,22 @@ std::unordered_map> keymap { { Key::Modifiers::Alt, 'x' }, [](Editor& editor, int count) { editor.select(select_whole_lines); } }, }; +class RegisterRestorer +{ +public: + RegisterRestorer(char name) + : m_name(name), + m_save(RegisterManager::instance()[name].content()) + {} + + ~RegisterRestorer() + { RegisterManager::instance()[m_name] = m_save; } + +private: + std::vector m_save; + char m_name; +}; + void exec_keys(const KeyList& keys, const Context& context) { @@ -830,11 +846,13 @@ void exec_keys(const KeyList& keys, return keys[pos++]; }; + RegisterRestorer quote('"'); + RegisterRestorer slash('/'); + Editor batch_editor(context.buffer()); Editor& editor = context.has_window() ? static_cast(context.window()) : static_cast(batch_editor); - scoped_edition edition(editor); int count = 0; diff --git a/src/register.hh b/src/register.hh index 365207ad7..75f883546 100644 --- a/src/register.hh +++ b/src/register.hh @@ -21,6 +21,7 @@ public: operator memoryview() const { return memoryview(m_content); } + const std::vector& content() const { return m_content; } private: std::vector m_content;