From d2b9cd6e60d69d6a1e1bb206a865d481bb739bf8 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 14 Nov 2011 14:10:11 +0000 Subject: [PATCH] DisplayBuffer: split now preserve iterator parameter that means that the given iterator points to the first part of the split (instead of the second in previous implementation). --- src/display_buffer.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/display_buffer.cc b/src/display_buffer.cc index 547cca2b..dbae0e4f 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -106,14 +106,18 @@ DisplayBuffer::iterator DisplayBuffer::split(iterator atom, const BufferIterator { assert(pos > atom->begin()); assert(pos < atom->end()); - DisplayAtom new_atom(atom->coord(), atom->begin(), pos, + + BufferIterator end = atom->m_end; + atom->m_end = pos; + + DisplayAtom new_atom(atom->end_coord(), pos, end, atom->fg_color(), atom->bg_color(), atom->attribute()); - atom->m_begin = pos; - atom->m_coord = new_atom.end_coord(); - iterator res = m_atoms.insert(atom, std::move(new_atom)); + iterator insert_pos = atom; + ++insert_pos; + m_atoms.insert(insert_pos, std::move(new_atom)); check_invariant(); - return res; + return atom; } void DisplayBuffer::check_invariant() const