diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-07-29 13:50:31 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-07-29 13:50:31 +0100 |
| commit | 4f452474c85beadfdf3604d80e89a94e77fa998d (patch) | |
| tree | 1abdfa73f6ae09fe3a86b53272173350c519f401 /src/normal.cc | |
| parent | af8e8d27d4a92a961ac696e6170856a66fd6e253 (diff) | |
non-regex based implementation of split_lines
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/normal.cc b/src/normal.cc index 8adb4956..be6b83b0 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -493,7 +493,18 @@ void split_regex(Context& context) void split_lines(Context& context) { - context.editor().multi_select(std::bind(split_selection, _1, _2, Regex{"^"})); + context.editor().multi_select([](const Buffer& buffer, const Selection& sel) { + if (sel.first().line == sel.last().line) + return SelectionList{ sel }; + SelectionList res; + auto min = sel.min(); + auto max = sel.max(); + res.push_back({min, {min.line, buffer[min.line].length()-1}}); + for (auto line = min.line+1; line < max.line; ++line) + res.push_back({line, {line, buffer[line].length()-1}}); + res.push_back({max.line, max}); + return res; + }); } void join_select_spaces(Context& context) |
