From 07e1fcf67b830a22a59eb61671a7ba603954a2a9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 31 Mar 2012 15:21:14 +0000 Subject: [PATCH] specialize BufferIterator::operator-- --- src/buffer_iterator.inl.hh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/buffer_iterator.inl.hh b/src/buffer_iterator.inl.hh index 034310b1..93517faa 100644 --- a/src/buffer_iterator.inl.hh +++ b/src/buffer_iterator.inl.hh @@ -202,11 +202,22 @@ inline BufferIterator& BufferIterator::operator++() ++m_coord.line; m_coord.column = 0; } + return *this; } inline BufferIterator& BufferIterator::operator--() { - return (*this -= 1); + if (column() == 0) + { + if (line() > 0) + { + --m_coord.line; + m_coord.column = m_buffer->m_lines[m_coord.line].length() - 1; + } + } + else + --m_coord.column; + return *this; } inline bool BufferIterator::is_begin() const