From a2aefa299874437a87e3ff0aec8f71d7a490408a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 15 Aug 2012 18:20:02 +0200 Subject: [PATCH] avoid keeping end of lines selected in Editor::erase --- src/editor.cc | 5 ++++- src/selection.cc | 6 ++++++ src/selection.hh | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) 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 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);