From 4f452474c85beadfdf3604d80e89a94e77fa998d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 29 Jul 2013 13:50:31 +0100 Subject: [PATCH] non-regex based implementation of split_lines --- src/normal.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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)