From 74076ef9b7e43ee0ddb9a9304bec32dda86ec2f4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 11 Jul 2017 22:35:42 +0900 Subject: [PATCH] Alternative, and hopefully safer implementation of / Fixes #1495 --- src/normal.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index 97243508..b676f36c 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1760,11 +1760,15 @@ void exec_user_mappings(Context& context, NormalParams params) template void add_empty_line(Context& context, NormalParams params) { - String new_lines{'\n', CharCount{std::max(params.count, 1)}}; - SelectionList sels = context.selections(); - for (auto& sel : sels) - sel.set(above ? sel.min().line : sel.max().line+1); - sels.insert(new_lines, InsertMode::InsertCursor); + int count = std::max(params.count, 1); + String new_lines{'\n', CharCount{count}}; + auto& buffer = context.buffer(); + auto& sels = context.selections(); + for (int i = 0; i < sels.size(); ++i) + { + auto line = (above ? sels[i].min().line : sels[i].max().line + 1) + (i * count); + buffer.insert(line, new_lines); + } } template