From 77dc9955d3920d0bb6441f7956197ba6722b44e9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 22 Feb 2013 18:45:27 +0100 Subject: [PATCH] Paste: use count for repetition --- src/main.cc | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/main.cc b/src/main.cc index 12f33e45..9c26c7ba 100644 --- a/src/main.cc +++ b/src/main.cc @@ -242,28 +242,17 @@ template void do_paste(Context& context) { Editor& editor = context.editor(); - int count = context.numeric_param(); auto strings = RegisterManager::instance()['"'].values(context); InsertMode mode = insert_mode; - if (count == 0) + for (auto& str : strings) { - for (auto& str : strings) - { - if (not str.empty() and str.back() == '\n') - { - mode = adapt_for_linewise(mode); - break; - } - } - editor.insert(strings, mode); - } - else if (count <= strings.size()) - { - auto& str = strings[count-1]; if (not str.empty() and str.back() == '\n') + { mode = adapt_for_linewise(mode); - editor.insert(str, mode); + break; + } } + editor.insert(strings, mode); } void do_select_regex(Context& context) @@ -588,8 +577,8 @@ std::unordered_map> keymap = { { Key::Modifiers::None, 'G' }, do_go }, { { Key::Modifiers::None, 'y' }, do_yank }, - { { Key::Modifiers::None, 'p' }, do_paste }, - { { Key::Modifiers::None, 'P' }, do_paste }, + { { Key::Modifiers::None, 'p' }, repeated(do_paste) }, + { { Key::Modifiers::None, 'P' }, repeated(do_paste) }, { { Key::Modifiers::Alt, 'p' }, do_paste }, { { Key::Modifiers::None, 's' }, do_select_regex },