From 90df4320b7c10e3b81d979d57b4a39ee1b0a574e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 10 Sep 2014 13:41:32 +0100 Subject: [PATCH] Add a small validation assert to catch a rare bug --- src/line_modification.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/line_modification.cc b/src/line_modification.cc index 5da287fc..62c76243 100644 --- a/src/line_modification.cc +++ b/src/line_modification.cc @@ -92,6 +92,9 @@ std::vector compute_line_modifications(const Buffer& buffer, s modif.new_line + modif.num_added - change.pos; const LineCount num_removed_from_added = std::min(num_removed, num_added_after_pos); + + kak_assert(modif.num_added >= num_removed_from_added); + modif.num_added -= num_removed_from_added; modif.num_removed += num_removed - num_removed_from_added;