diff --git a/src/input_handler.cc b/src/input_handler.cc index fecf09bb..4b4bd300 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -246,7 +246,7 @@ public: get_face("Information"), InfoStyle::Prompt); it->func(context(), m_params); } - m_params = { 0, '"' }; + m_params = { 0, 0 }; } context().hooks().run_hook("NormalKey", key_to_str(key), context()); @@ -261,7 +261,7 @@ public: atoms.push_back({ "; param=", Face(Color::Yellow) }); atoms.push_back({ to_string(m_params.count), Face(Color::Green) }); } - if (m_params.reg != '"') + if (m_params.reg) { atoms.push_back({ "; reg=", Face(Color::Yellow) }); atoms.push_back({ StringView(m_params.reg).str(), Face(Color::Green) }); @@ -272,7 +272,7 @@ public: KeymapMode keymap_mode() const override { return KeymapMode::Normal; } private: - NormalParams m_params = { 0, '"' }; + NormalParams m_params = { 0, 0 }; bool m_hooks_disabled = false; bool m_waiting_for_reg = false; Timer m_idle_timer; diff --git a/src/normal.cc b/src/normal.cc index a2985fc4..ecd4c60b 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -460,15 +460,17 @@ void select_next_match(const Buffer& buffer, SelectionList& selections, void yank(Context& context, NormalParams params) { - RegisterManager::instance()[params.reg] = context.selections_content(); + const char reg = params.reg ? params.reg : '"'; + RegisterManager::instance()[reg] = context.selections_content(); context.print_status({ format("yanked {} selections to register {}", - context.selections().size(), params.reg), + context.selections().size(), reg), get_face("Information") }); } void erase_selections(Context& context, NormalParams params) { - RegisterManager::instance()[params.reg] = context.selections_content(); + const char reg = params.reg ? params.reg : '"'; + RegisterManager::instance()[reg] = context.selections_content(); ScopedEdition edition(context); context.selections().erase(); context.selections().avoid_eol(); @@ -476,7 +478,8 @@ void erase_selections(Context& context, NormalParams params) void change(Context& context, NormalParams params) { - RegisterManager::instance()[params.reg] = context.selections_content(); + const char reg = params.reg ? params.reg : '"'; + RegisterManager::instance()[reg] = context.selections_content(); enter_insert_mode(context, params); } @@ -493,7 +496,8 @@ constexpr InsertMode adapt_for_linewise(InsertMode mode) template void paste(Context& context, NormalParams params) { - auto strings = RegisterManager::instance()[params.reg].values(context); + const char reg = params.reg ? params.reg : '"'; + auto strings = RegisterManager::instance()[reg].values(context); InsertMode effective_mode = mode; for (auto& str : strings) { @@ -510,7 +514,8 @@ void paste(Context& context, NormalParams params) template void paste_all(Context& context, NormalParams params) { - auto strings = RegisterManager::instance()[params.reg].values(context); + const char reg = params.reg ? params.reg : '"'; + auto strings = RegisterManager::instance()[reg].values(context); InsertMode effective_mode = mode; String all; Vector offsets;