misc cleanups

This commit is contained in:
Maxime Coste 2012-08-15 17:55:58 +02:00
parent 346108ec62
commit 260b30e6d9
3 changed files with 4 additions and 6 deletions

View File

@ -98,7 +98,8 @@ BufferIterator Buffer::iterator_at_line_begin(const BufferIterator& iterator) co
BufferIterator Buffer::iterator_at_line_end(const BufferIterator& iterator) const BufferIterator Buffer::iterator_at_line_end(const BufferIterator& iterator) const
{ {
BufferPos line = iterator.line(); 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 BufferIterator Buffer::begin() const

View File

@ -43,8 +43,7 @@ void expand_tabulations(Buffer& buffer, BufferIterator& position, String& conten
if (content == "\t") if (content == "\t")
{ {
int column = 0; int column = 0;
BufferCoord pos = buffer.line_and_column_at(position); for (auto line_it = buffer.iterator_at_line_begin(position);
for (auto line_it = buffer.iterator_at({pos.line, 0});
line_it != position; ++line_it) line_it != position; ++line_it)
{ {
assert(*line_it != '\n'); assert(*line_it != '\n');

View File

@ -188,10 +188,8 @@ void expand_tabulations(Window& window, DisplayBuffer& display_buffer)
if (it+1 != end) if (it+1 != end)
atom_it = line.split(atom_it, it+1); atom_it = line.split(atom_it, it+1);
BufferCoord pos = it.buffer().line_and_column_at(it);
int column = 0; 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) line_it != it; ++line_it)
{ {
assert(*line_it != '\n'); assert(*line_it != '\n');