diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-06-27 23:49:34 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-06-27 23:49:34 +0200 |
| commit | 5b4ef23b9d8fcc516b90690a12e8403a17364ccc (patch) | |
| tree | 1994a52a32673d13ebf72652f35432264183f624 /src/buffer.cc | |
| parent | b1f31d2e1285b6586f22f1b0616a3767148377b9 (diff) | |
more tolerant Buffer::string
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index 26155bda..c8853708 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -129,15 +129,15 @@ LineCount Buffer::line_count() const String Buffer::string(const BufferCoord& begin, const BufferCoord& end) const { String res; - for (LineCount line = begin.line; line <= end.line; ++line) + for (auto line = begin.line; line <= end.line and line < line_count(); ++line) { - ByteCount start = 0; - if (line == begin.line) - start = begin.column; - ByteCount count = -1; - if (line == end.line) - count = end.column - start; - res += m_lines[line].content.substr(start, count); + ByteCount start = 0; + if (line == begin.line) + start = begin.column; + ByteCount count = -1; + if (line == end.line) + count = end.column - start; + res += m_lines[line].content.substr(start, count); } return res; } |
