From d142db80f2393d7b74b2088cf8df986b592b9675 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 27 Nov 2017 17:29:19 +0800 Subject: [PATCH] Fix compute_modified_ranges corner case that would crash on undo Fixes #1506 Fixes #1215 --- src/selection.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/selection.cc b/src/selection.cc index 0ea173ce..3574afaa 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -167,6 +167,8 @@ Vector compute_modified_ranges(Buffer& buffer, size_t timestamp) kak_assert(std::is_sorted(ranges.begin() + prev_size, ranges.end(), compare_selections)); std::inplace_merge(ranges.begin(), ranges.begin() + prev_size, ranges.end(), compare_selections); + // The newly added ranges might be overlapping pre-existing ones + ranges.erase(merge_overlapping(ranges.begin(), ranges.end(), dummy, overlaps), ranges.end()); } const auto end_coord = buffer.end_coord();