Fix splitting selecting the first buffer char when there is a match at buffer begin
This commit is contained in:
parent
da40828801
commit
25a31534ec
|
@ -654,6 +654,7 @@ void split_selections(SelectionList& selections, const Regex& regex, unsigned ca
|
|||
Vector<Selection> result;
|
||||
auto& buffer = selections.buffer();
|
||||
auto buf_end = buffer.end();
|
||||
auto buf_begin = buffer.begin();
|
||||
for (auto& sel : selections)
|
||||
{
|
||||
auto begin = buffer.iterator_at(sel.min());
|
||||
|
@ -671,8 +672,12 @@ void split_selections(SelectionList& selections, const Regex& regex, unsigned ca
|
|||
if (end == buf_end)
|
||||
continue;
|
||||
|
||||
if (end != buf_begin)
|
||||
{
|
||||
end = ensure_char_start(buffer, end);
|
||||
result.push_back(keep_direction({ begin.coord(), (begin == end) ? end.coord() : utf8::previous(end, begin).coord() }, sel));
|
||||
auto sel_end = (begin == end) ? end : utf8::previous(end, begin);
|
||||
result.push_back(keep_direction({ begin.coord(), sel_end.coord() }, sel));
|
||||
}
|
||||
begin = ensure_char_start(buffer, (*re_it)[capture].second);
|
||||
}
|
||||
if (begin.coord() <= sel.max())
|
||||
|
|
1
test/unit/split-at-begin/cmd
Normal file
1
test/unit/split-at-begin/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
%S\w+<ret>
|
1
test/unit/split-at-begin/in
Normal file
1
test/unit/split-at-begin/in
Normal file
|
@ -0,0 +1 @@
|
|||
foo bar baz
|
2
test/unit/split-at-begin/selections
Normal file
2
test/unit/split-at-begin/selections
Normal file
|
@ -0,0 +1,2 @@
|
|||
: :
|
||||
|
Loading…
Reference in New Issue
Block a user