From c03506ca0472891f9727e1777746bf6c85d80fd0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 27 Feb 2012 19:51:30 +0000 Subject: [PATCH] save and restore " and / registers in exec_keys --- src/main.cc | 20 +++++++++++++++++++- src/register.hh | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index 25195303..1d848f43 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 365207ad..75f88354 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;