From 87fcfda5089345f698d442f9411130a3fb1eba7f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 5 Jun 2015 13:10:30 +0100 Subject: [PATCH] Avoid buffer end in compute_modified_ranges --- src/selection.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/selection.cc b/src/selection.cc index 602edd96..1ea2fdbb 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -321,6 +321,11 @@ Vector compute_modified_ranges(Buffer& buffer, size_t timestamp) for (auto& sel : ranges) { + if (buffer.is_end(sel.anchor())) + sel.anchor() = buffer.back_coord(); + if (buffer.is_end(sel.cursor())) + sel.cursor() = buffer.back_coord(); + if (sel.anchor() != sel.cursor()) sel.cursor() = buffer.char_prev(sel.cursor()); }