diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-05-29 23:12:04 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-05-29 23:12:04 +1000 |
| commit | 1ebea85e6f07aeb6a8287b8043480f56f0e58edb (patch) | |
| tree | c67f3e546db9a8582b524839f7f7e89c0e60c4d7 /src | |
| parent | 7efdbb456d6855fe72790050d067c8a1b66993ba (diff) | |
Do not merge selections on backspace in insert mode
Fixes #2861
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_handler.cc | 2 | ||||
| -rw-r--r-- | src/selection.cc | 18 | ||||
| -rw-r--r-- | src/selection.hh | 4 |
3 files changed, 14 insertions, 10 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index 58b8d0d2..750ec1d4 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -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) { 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<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,20 +242,22 @@ void update_selections(Vector<Selection>& 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(); } diff --git a/src/selection.hh b/src/selection.hh index f83d4e4b..df1459e6 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -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; |
