From 8795a5673143dfac24656e3c1fe0f998665f1475 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 27 Jun 2015 17:39:09 +0100 Subject: [PATCH] Merge overlapping selections before erasing Overlapping selections on erase confuse the ForwardChangeTracker and will confuse the user, Fixes #298 --- src/selection.cc | 5 +++++ test/compose/del-empty-line/cmd | 1 + test/compose/del-empty-line/in | 3 +++ test/compose/del-empty-line/out | 2 ++ 4 files changed, 11 insertions(+) create mode 100644 test/compose/del-empty-line/cmd create mode 100644 test/compose/del-empty-line/in create mode 100644 test/compose/del-empty-line/out diff --git a/src/selection.cc b/src/selection.cc index b5b60528..232b6f6a 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -508,6 +508,10 @@ void SelectionList::insert(ConstArrayView strings, InsertMode mode, void SelectionList::erase() { update(); + + m_selections.erase(merge_overlapping(begin(), end(), m_main, overlaps), + end()); + ForwardChangesTracker changes_tracker; for (auto& sel : m_selections) { @@ -529,6 +533,7 @@ void SelectionList::erase() if (sel.cursor() > back_coord) sel.cursor() = back_coord; } + m_buffer->check_invariant(); } diff --git a/test/compose/del-empty-line/cmd b/test/compose/del-empty-line/cmd new file mode 100644 index 00000000..4169006e --- /dev/null +++ b/test/compose/del-empty-line/cmd @@ -0,0 +1 @@ +CCdd diff --git a/test/compose/del-empty-line/in b/test/compose/del-empty-line/in new file mode 100644 index 00000000..c73eb70f --- /dev/null +++ b/test/compose/del-empty-line/in @@ -0,0 +1,3 @@ +asdf + +asdf diff --git a/test/compose/del-empty-line/out b/test/compose/del-empty-line/out new file mode 100644 index 00000000..ca7ee96a --- /dev/null +++ b/test/compose/del-empty-line/out @@ -0,0 +1,2 @@ +df +df