From 7bcfbd055c19c2cf37f5dd64a7e532eb38585052 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 11 Jun 2017 12:24:45 +0100 Subject: [PATCH] Fix corner case in compute_modified_ranges --- src/selection.cc | 2 +- test/regression/0-undo-change-at-eof/cmd | 1 + test/regression/0-undo-change-at-eof/in | 2 ++ test/regression/0-undo-change-at-eof/out | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/regression/0-undo-change-at-eof/cmd create mode 100644 test/regression/0-undo-change-at-eof/in create mode 100644 test/regression/0-undo-change-at-eof/out diff --git a/src/selection.cc b/src/selection.cc index 4724e896..14879386 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -183,7 +183,7 @@ Vector compute_modified_ranges(Buffer& buffer, size_t timestamp) } auto touches = [&](const Selection& lhs, const Selection& rhs) { - return buffer.char_next(lhs.max()) >= rhs.min(); + return lhs.max() == end_coord or buffer.char_next(lhs.max()) >= rhs.min(); }; size_t dummy = 0; ranges.erase(merge_overlapping(ranges.begin(), ranges.end(), dummy, touches), ranges.end()); diff --git a/test/regression/0-undo-change-at-eof/cmd b/test/regression/0-undo-change-at-eof/cmd new file mode 100644 index 00000000..b2bb8707 --- /dev/null +++ b/test/regression/0-undo-change-at-eof/cmd @@ -0,0 +1 @@ +yjxRu diff --git a/test/regression/0-undo-change-at-eof/in b/test/regression/0-undo-change-at-eof/in new file mode 100644 index 00000000..cc60e6f5 --- /dev/null +++ b/test/regression/0-undo-change-at-eof/in @@ -0,0 +1,2 @@ +copy +paste diff --git a/test/regression/0-undo-change-at-eof/out b/test/regression/0-undo-change-at-eof/out new file mode 100644 index 00000000..cc60e6f5 --- /dev/null +++ b/test/regression/0-undo-change-at-eof/out @@ -0,0 +1,2 @@ +copy +paste