From 260b30e6d90eee942e965d3d96038fb6632b763a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 15 Aug 2012 17:55:58 +0200 Subject: [PATCH] misc cleanups --- src/buffer.cc | 3 ++- src/filters.cc | 3 +-- src/highlighters.cc | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/buffer.cc b/src/buffer.cc index 8cec62d2..76a2009d 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -98,7 +98,8 @@ BufferIterator Buffer::iterator_at_line_begin(const BufferIterator& iterator) co BufferIterator Buffer::iterator_at_line_end(const BufferIterator& iterator) const { BufferPos line = iterator.line(); - return ++BufferIterator(*this, { line, std::max(line_length(line) - 1, 0) }); + assert(line_length(line) > 0); + return ++BufferIterator(*this, { line, line_length(line) - 1 }); } BufferIterator Buffer::begin() const diff --git a/src/filters.cc b/src/filters.cc index 4a392545..8df8b597 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -43,8 +43,7 @@ void expand_tabulations(Buffer& buffer, BufferIterator& position, String& conten if (content == "\t") { int column = 0; - BufferCoord pos = buffer.line_and_column_at(position); - for (auto line_it = buffer.iterator_at({pos.line, 0}); + for (auto line_it = buffer.iterator_at_line_begin(position); line_it != position; ++line_it) { assert(*line_it != '\n'); diff --git a/src/highlighters.cc b/src/highlighters.cc index 09ef7e65..d41456c4 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -188,10 +188,8 @@ void expand_tabulations(Window& window, DisplayBuffer& display_buffer) if (it+1 != end) atom_it = line.split(atom_it, it+1); - BufferCoord pos = it.buffer().line_and_column_at(it); - int column = 0; - for (auto line_it = it.buffer().iterator_at({pos.line, 0}); + for (auto line_it = it.buffer().iterator_at_line_begin(it); line_it != it; ++line_it) { assert(*line_it != '\n');