diff --git a/src/selection.cc b/src/selection.cc index 8ad933a4..91527080 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -527,6 +527,15 @@ void SelectionList::erase() sel.anchor() = sel.cursor() = m_buffer->clamp(pos.coord()); changes_tracker.update(*m_buffer, m_timestamp); } + + ByteCoord back_coord = m_buffer->back_coord(); + for (auto& sel : m_selections) + { + if (sel.anchor() > back_coord) + sel.anchor() = back_coord; + if (sel.cursor() > back_coord) + sel.cursor() = back_coord; + } m_buffer->check_invariant(); } diff --git a/test/compose/eof-multi-delete/cmd b/test/compose/eof-multi-delete/cmd new file mode 100644 index 00000000..5c0212bc --- /dev/null +++ b/test/compose/eof-multi-delete/cmd @@ -0,0 +1 @@ +%keepd diff --git a/test/compose/eof-multi-delete/in b/test/compose/eof-multi-delete/in new file mode 100644 index 00000000..7270a5c6 --- /dev/null +++ b/test/compose/eof-multi-delete/in @@ -0,0 +1,6 @@ +delete +keep +delete +keep +delete +delete diff --git a/test/compose/eof-multi-delete/out b/test/compose/eof-multi-delete/out new file mode 100644 index 00000000..16acb76c --- /dev/null +++ b/test/compose/eof-multi-delete/out @@ -0,0 +1,2 @@ +keep +keep