diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-02-22 22:02:43 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-02-22 22:02:43 +0000 |
| commit | 416a1805b3ede28db36ea9889e67d7593d1f51c4 (patch) | |
| tree | d3ae093b647d67bb4dd4dbb944f3d43e1c407612 /src/buffer.cc | |
| parent | a386315bde576cc77c22ca7677de51f86f97755c (diff) | |
Fix last line handling in buffer
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index 409ee4e0..8f22d1f4 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -121,7 +121,10 @@ BufferSize Buffer::length() const BufferSize Buffer::line_count() const { - return m_lines.size(); + if (m_lines.back() == m_content.size()) + return m_lines.size() - 1; + else + return m_lines.size(); } BufferString Buffer::string(const BufferIterator& begin, const BufferIterator& end) const @@ -191,7 +194,7 @@ void Buffer::compute_lines() { m_lines.clear(); m_lines.push_back(0); - for (BufferPos i = 0; i + 1 < m_content.size(); ++i) + for (BufferPos i = 0; i < m_content.size(); ++i) { if (m_content[i] == '\n') m_lines.push_back(i + 1); |
