diff options
| author | Frank LENORMAND <lenormf@gmail.com> | 2018-06-30 13:18:50 +0300 |
|---|---|---|
| committer | Frank LENORMAND <lenormf@gmail.com> | 2018-06-30 14:39:15 +0300 |
| commit | 266ce73de7714f4db09df836985a22b035fa82e7 (patch) | |
| tree | 5ad99a2d5efb974da2b64353c184567b08a9174f /src/normal.cc | |
| parent | 43b72770ec5ef15723b0ee5c1901a39e23039de8 (diff) | |
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
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 8 |
1 files 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++; } } } |
