Fix split selecting the buffer end

Fixes #241
This commit is contained in:
Maxime Coste 2014-12-17 13:21:20 +00:00
parent e0c452adb6
commit 3b9f40fd58

View File

@ -535,6 +535,7 @@ void split_selections(SelectionList& selections, const Regex& regex)
{
std::vector<Selection> result;
auto& buffer = selections.buffer();
auto buf_end = buffer.end();
for (auto& sel : selections)
{
auto begin = buffer.iterator_at(sel.min());
@ -545,6 +546,8 @@ void split_selections(SelectionList& selections, const Regex& regex)
for (; re_it != re_end; ++re_it)
{
BufferIterator end = (*re_it)[0].first;
if (end == buf_end)
continue;
result.push_back(keep_direction({ begin.coord(), (begin == end) ? end.coord() : utf8::previous(end, begin).coord() }, sel));
begin = (*re_it)[0].second;