diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-07-11 22:35:42 +0900 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-07-11 22:35:42 +0900 |
| commit | 74076ef9b7e43ee0ddb9a9304bec32dda86ec2f4 (patch) | |
| tree | 1b8039cac0a15d2a8c94ccf9775ab141901f25ce /src/normal.cc | |
| parent | 81b5de6fd86b4d1db25cf7e25f3e29bdb6ad9689 (diff) | |
Alternative, and hopefully safer implementation of <a-o>/<a-O>
Fixes #1495
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 14 |
1 files 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<bool above> 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<typename T> |
