avoid keeping end of lines selected in Editor::erase

This commit is contained in:
Maxime Coste 2012-08-15 18:20:02 +02:00
parent 416785f53c
commit a2aefa2998
3 changed files with 11 additions and 1 deletions

View File

@ -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>

View File

@ -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());

View File

@ -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);