parent
7efdbb456d
commit
1ebea85e6f
|
@ -1235,6 +1235,8 @@ public:
|
|||
|
||||
if (not main_char.empty())
|
||||
context().hooks().run_hook(Hook::InsertDelete, main_char, context());
|
||||
|
||||
context().selections_write_only().update(false);
|
||||
}
|
||||
else if (key == Key::Delete)
|
||||
{
|
||||
|
|
|
@ -218,7 +218,7 @@ void clamp_selections(Vector<Selection>& selections, const Buffer& buffer)
|
|||
clamp(sel, buffer);
|
||||
}
|
||||
|
||||
void update_selections(Vector<Selection>& selections, size_t& main, Buffer& buffer, size_t timestamp)
|
||||
void update_selections(Vector<Selection>& selections, size_t& main, Buffer& buffer, size_t timestamp, bool merge)
|
||||
{
|
||||
if (timestamp == buffer.timestamp())
|
||||
return;
|
||||
|
@ -242,6 +242,7 @@ void update_selections(Vector<Selection>& selections, size_t& main, Buffer& buff
|
|||
}
|
||||
kak_assert(std::is_sorted(selections.begin(), selections.end(),
|
||||
compare_selections));
|
||||
if (merge)
|
||||
selections.erase(
|
||||
merge_overlapping(selections.begin(), selections.end(),
|
||||
main, overlaps), selections.end());
|
||||
|
@ -249,13 +250,14 @@ void update_selections(Vector<Selection>& selections, size_t& main, Buffer& buff
|
|||
for (auto& sel : selections)
|
||||
clamp(sel, buffer);
|
||||
|
||||
if (merge)
|
||||
selections.erase(merge_overlapping(selections.begin(), selections.end(),
|
||||
main, overlaps), selections.end());
|
||||
}
|
||||
|
||||
void SelectionList::update()
|
||||
void SelectionList::update(bool merge)
|
||||
{
|
||||
update_selections(m_selections, m_main, *m_buffer, m_timestamp);
|
||||
update_selections(m_selections, m_main, *m_buffer, m_timestamp, merge);
|
||||
check_invariant();
|
||||
m_timestamp = m_buffer->timestamp();
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ inline bool overlaps(const Selection& lhs, const Selection& rhs)
|
|||
}
|
||||
|
||||
void update_selections(Vector<Selection>& selections, size_t& main,
|
||||
Buffer& buffer, size_t timestamp);
|
||||
Buffer& buffer, size_t timestamp, bool merge = true);
|
||||
|
||||
bool compare_selections(const Selection& lhs, const Selection& rhs);
|
||||
void sort_selections(Vector<Selection>& selections, size_t& main);
|
||||
|
@ -97,7 +97,7 @@ struct SelectionList
|
|||
struct UnsortedTag {};
|
||||
SelectionList(UnsortedTag, Buffer& buffer, Vector<Selection> s, size_t timestamp, size_t main);
|
||||
|
||||
void update();
|
||||
void update(bool merge = true);
|
||||
|
||||
void check_invariant() const;
|
||||
|
||||
|
|
1
test/regression/2861-backspace-merges-selections/cmd
Normal file
1
test/regression/2861-backspace-merges-selections/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
a<backspace>oo
|
1
test/regression/2861-backspace-merges-selections/in
Normal file
1
test/regression/2861-backspace-merges-selections/in
Normal file
|
@ -0,0 +1 @@
|
|||
%(fo)%(fo)%(fo)
|
1
test/regression/2861-backspace-merges-selections/out
Normal file
1
test/regression/2861-backspace-merges-selections/out
Normal file
|
@ -0,0 +1 @@
|
|||
foofoofoo
|
Loading…
Reference in New Issue
Block a user