diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor.cc | 5 | ||||
| -rw-r--r-- | src/selection.cc | 6 | ||||
| -rw-r--r-- | src/selection.hh | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/src/editor.cc b/src/editor.cc index b262698b..06f47149 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -21,8 +21,11 @@ Editor::Editor(Buffer& buffer) void Editor::erase() { scoped_edition edition(*this); - for (auto& sel : selections()) + for (auto& sel : m_selections.back()) + { m_buffer.erase(sel.begin(), sel.end()); + sel.avoid_eol(); + } } template<bool append> diff --git a/src/selection.cc b/src/selection.cc index a892e9fc..6f483dc6 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -54,6 +54,12 @@ void Selection::merge_with(const Selection& selection) m_last = selection.m_last; } +void Selection::avoid_eol() +{ + m_first.clamp(true); + m_last.clamp(true); +} + void Selection::on_insert(const BufferIterator& begin, const BufferIterator& end) { m_first.on_insert(begin.coord(), end.coord()); diff --git a/src/selection.hh b/src/selection.hh index 29a008a2..7081e427 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -29,6 +29,7 @@ struct Selection : public BufferChangeListener const BufferIterator& last() const { return m_last; } void merge_with(const Selection& selection); + void avoid_eol(); void on_insert(const BufferIterator& begin, const BufferIterator& end); void on_erase(const BufferIterator& begin, const BufferIterator& end); |
