Paste: use count for repetition

This commit is contained in:
Maxime Coste 2013-02-22 18:45:27 +01:00
parent 4b11f73f1e
commit 77dc9955d3

View File

@ -242,11 +242,8 @@ template<InsertMode insert_mode>
void do_paste(Context& context) void do_paste(Context& context)
{ {
Editor& editor = context.editor(); Editor& editor = context.editor();
int count = context.numeric_param();
auto strings = RegisterManager::instance()['"'].values(context); auto strings = RegisterManager::instance()['"'].values(context);
InsertMode mode = insert_mode; InsertMode mode = insert_mode;
if (count == 0)
{
for (auto& str : strings) for (auto& str : strings)
{ {
if (not str.empty() and str.back() == '\n') if (not str.empty() and str.back() == '\n')
@ -257,14 +254,6 @@ void do_paste(Context& context)
} }
editor.insert(strings, mode); 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);
}
}
void do_select_regex(Context& context) void do_select_regex(Context& context)
{ {
@ -588,8 +577,8 @@ std::unordered_map<Key, std::function<void (Context& context)>> keymap =
{ { Key::Modifiers::None, 'G' }, do_go<SelectMode::Extend> }, { { Key::Modifiers::None, 'G' }, do_go<SelectMode::Extend> },
{ { Key::Modifiers::None, 'y' }, do_yank }, { { Key::Modifiers::None, 'y' }, do_yank },
{ { Key::Modifiers::None, 'p' }, do_paste<InsertMode::Append> }, { { Key::Modifiers::None, 'p' }, repeated(do_paste<InsertMode::Append>) },
{ { Key::Modifiers::None, 'P' }, do_paste<InsertMode::Insert> }, { { Key::Modifiers::None, 'P' }, repeated(do_paste<InsertMode::Insert>) },
{ { Key::Modifiers::Alt, 'p' }, do_paste<InsertMode::Replace> }, { { Key::Modifiers::Alt, 'p' }, do_paste<InsertMode::Replace> },
{ { Key::Modifiers::None, 's' }, do_select_regex }, { { Key::Modifiers::None, 's' }, do_select_regex },