diff --git a/src/editor.cc b/src/editor.cc index 3a81a4d00..b1afe6ee9 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -211,18 +211,21 @@ void Editor::remove_selection(int index) m_selections.erase(m_selections.begin() + index); } -void Editor::select(const BufferIterator& iterator, SelectMode mode) +void Editor::select(const Selection& selection, SelectMode mode) { if (mode == SelectMode::Replace) - m_selections = SelectionList{ {iterator, iterator} }; + m_selections = SelectionList{ selection }; else if (mode == SelectMode::Extend) { for (auto& sel : m_selections) - sel.last() = iterator; + sel.merge_with(selection); sort_and_merge_overlapping(m_selections); } else if (mode == SelectMode::Append) - assert(false); + { + m_selections.push_back(selection); + sort_and_merge_overlapping(m_selections); + } } void Editor::select(SelectionList selections) diff --git a/src/editor.hh b/src/editor.hh index 3ca639c24..dda0fe077 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -62,7 +62,10 @@ public: void flip_selections(); void keep_selection(int index); void remove_selection(int index); - void select(const BufferIterator& iterator, + void select(const BufferIterator& it, + SelectMode mode = SelectMode::Replace) + { select(Selection{ it, it }, mode); } + void select(const Selection& sel, SelectMode mode = SelectMode::Replace); void select(const Selector& selector, SelectMode mode = SelectMode::Replace);