From b988871df6636c1b7d5938d1ac2d2700a6a59158 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 14 Jul 2016 21:14:17 +0100 Subject: [PATCH] Ensure selections are sorted and non overlapping in selections_list_from_string --- src/selection.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/selection.cc b/src/selection.cc index 36c1cdf2..47597a50 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -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)}; }