parent
e8093a12a0
commit
1f6c2b87ff
|
@ -936,8 +936,9 @@ void split_regex(Context& context, NormalParams params)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void split_lines(Context& context, NormalParams)
|
void split_lines(Context& context, NormalParams params)
|
||||||
{
|
{
|
||||||
|
const LineCount count{params.count == 0 ? 1 : params.count};
|
||||||
auto& selections = context.selections();
|
auto& selections = context.selections();
|
||||||
auto& buffer = context.buffer();
|
auto& buffer = context.buffer();
|
||||||
Vector<Selection> res;
|
Vector<Selection> res;
|
||||||
|
@ -950,10 +951,14 @@ void split_lines(Context& context, NormalParams)
|
||||||
}
|
}
|
||||||
auto min = sel.min();
|
auto min = sel.min();
|
||||||
auto max = sel.max();
|
auto max = sel.max();
|
||||||
res.push_back(keep_direction({min, {min.line, buffer[min.line].length()-1}}, sel));
|
for (auto line = min.line; line <= max.line; line += count)
|
||||||
for (auto line = min.line+1; line < max.line; ++line)
|
{
|
||||||
res.push_back(keep_direction({line, {line, buffer[line].length()-1}}, sel));
|
auto last_line = std::min(line + count - 1, buffer.line_count() - 1);
|
||||||
res.push_back(keep_direction({max.line, max}, sel));
|
res.push_back(keep_direction({
|
||||||
|
std::max<BufferCoord>(min, line),
|
||||||
|
std::min<BufferCoord>(max, {last_line, buffer[last_line].length() - 1})
|
||||||
|
}, sel));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
selections = std::move(res);
|
selections = std::move(res);
|
||||||
}
|
}
|
||||||
|
|
1
test/normal/split-multiple-lines/cmd
Normal file
1
test/normal/split-multiple-lines/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
%2<a-s>
|
5
test/normal/split-multiple-lines/in
Normal file
5
test/normal/split-multiple-lines/in
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
line 1
|
||||||
|
line 2
|
||||||
|
line 3
|
||||||
|
line 4
|
||||||
|
line 5
|
6
test/normal/split-multiple-lines/selections
Normal file
6
test/normal/split-multiple-lines/selections
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
line 1
|
||||||
|
line 2
|
||||||
|
:line 3
|
||||||
|
line 4
|
||||||
|
:line 5
|
||||||
|
|
Loading…
Reference in New Issue
Block a user