From 44ca4d23de3508b668736ddad902afdb2a941e38 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 17 Jan 2013 18:46:45 +0100 Subject: [PATCH] Fix sort_and_merge_overlapping --- src/editor.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/editor.cc b/src/editor.cc index cd1b760f..9fcc0f15 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -142,10 +142,10 @@ static void sort_and_merge_overlapping(SelectionList& selections) Range back = selections.back(); auto back_rank = std::count_if(selections.begin(), selections.end(), [&](const Selection& sel) - { return sel.begin() < back.begin(); }); - std::sort(selections.begin(), selections.end(), compare_selections); + { return sel.begin() <= back.begin(); }); + std::stable_sort(selections.begin(), selections.end(), compare_selections); if (back_rank < selections.size() - 1) - std::rotate(selections.begin(), selections.begin() + back_rank + 1, + std::rotate(selections.begin(), selections.begin() + back_rank, selections.end()); assert(selections.back() == back);