From 1ebea85e6f07aeb6a8287b8043480f56f0e58edb Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 29 May 2019 23:12:04 +1000 Subject: Do not merge selections on backspace in insert mode Fixes #2861 --- src/selection.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/selection.cc') diff --git a/src/selection.cc b/src/selection.cc index 30ff599b..9e300af6 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -218,7 +218,7 @@ void clamp_selections(Vector& selections, const Buffer& buffer) clamp(sel, buffer); } -void update_selections(Vector& selections, size_t& main, Buffer& buffer, size_t timestamp) +void update_selections(Vector& selections, size_t& main, Buffer& buffer, size_t timestamp, bool merge) { if (timestamp == buffer.timestamp()) return; @@ -242,20 +242,22 @@ void update_selections(Vector& selections, size_t& main, Buffer& buff } kak_assert(std::is_sorted(selections.begin(), selections.end(), compare_selections)); - selections.erase( - merge_overlapping(selections.begin(), selections.end(), - main, overlaps), selections.end()); + if (merge) + selections.erase( + merge_overlapping(selections.begin(), selections.end(), + main, overlaps), selections.end()); } for (auto& sel : selections) clamp(sel, buffer); - selections.erase(merge_overlapping(selections.begin(), selections.end(), - main, overlaps), selections.end()); + 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(); } -- cgit v1.2.3