Merge overlapping selections before erasing

Overlapping selections on erase confuse the ForwardChangeTracker
and will confuse the user,

Fixes #298
This commit is contained in:
Maxime Coste 2015-06-27 17:39:09 +01:00
parent 373ad05f29
commit 8795a56731
4 changed files with 11 additions and 0 deletions

View File

@ -508,6 +508,10 @@ void SelectionList::insert(ConstArrayView<String> strings, InsertMode mode,
void SelectionList::erase() void SelectionList::erase()
{ {
update(); update();
m_selections.erase(merge_overlapping(begin(), end(), m_main, overlaps),
end());
ForwardChangesTracker changes_tracker; ForwardChangesTracker changes_tracker;
for (auto& sel : m_selections) for (auto& sel : m_selections)
{ {
@ -529,6 +533,7 @@ void SelectionList::erase()
if (sel.cursor() > back_coord) if (sel.cursor() > back_coord)
sel.cursor() = back_coord; sel.cursor() = back_coord;
} }
m_buffer->check_invariant(); m_buffer->check_invariant();
} }

View File

@ -0,0 +1 @@
CCdd

View File

@ -0,0 +1,3 @@
asdf
asdf

View File

@ -0,0 +1,2 @@
df
df