Ensure selections are sorted and non overlapping in selections_list_from_string

This commit is contained in:
Maxime Coste 2016-07-14 21:14:17 +01:00
parent 52d3b60aaa
commit b988871df6

View File

@ -613,6 +613,10 @@ SelectionList selection_list_from_string(Buffer& buffer, StringView desc)
clamp(sel, buffer);
sels.push_back(sel);
}
size_t main = 0;
std::sort(sels.begin(), sels.end(), compare_selections);
sels.erase(merge_overlapping(sels.begin(), sels.end(), main, overlaps), sels.end());
return {buffer, std::move(sels)};
}