From 266ce73de7714f4db09df836985a22b035fa82e7 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Sat, 30 Jun 2018 13:18:50 +0300 Subject: [PATCH] src: Make `C` skip empty lines This commits changes the way `C` behaves when the next line is empty: instead of stopping the selection, it will now jump to the next line that can hold a selection as big as the current one. The primitive's count parameter holds the maximum amount of selections that should be added to the current one. Closes #2061 --- src/normal.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index 0fe60ef8..29af4d4b 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1386,9 +1386,11 @@ void copy_selections_on_next_lines(Context& context, NormalParams params) main_index = result.size(); result.push_back(std::move(sel)); const LineCount height = std::max(anchor.line, cursor.line) - std::min(anchor.line, cursor.line) + 1; - for (int i = 0; i < std::max(params.count, 1); ++i) + const size_t max_lines = std::max(params.count, 1); + + for (size_t i = 0, nb_sels = 0; nb_sels < max_lines; ++i) { - LineCount offset = direction * (i + 1) * height; + LineCount offset = direction * (i + 1) * height; const LineCount anchor_line = anchor.line + offset; const LineCount cursor_line = cursor.line + offset; @@ -1407,6 +1409,8 @@ void copy_selections_on_next_lines(Context& context, NormalParams params) main_index = result.size(); result.emplace_back(BufferCoord{anchor_line, anchor_byte}, BufferCoordAndTarget{cursor_line, cursor_byte, cursor.target}); + + nb_sels++; } } }