non-regex based implementation of split_lines

This commit is contained in:
Maxime Coste 2013-07-29 13:50:31 +01:00
parent af8e8d27d4
commit 4f452474c8

View File

@ -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)