diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-08-10 14:22:57 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-08-10 14:22:57 +0200 |
| commit | 54b599c1a72bdb4cf7dfb54074f69f21d3cd275a (patch) | |
| tree | 01c87b39ea584ff7149e1451210c4d41dfe4fd9c /src/buffer.cc | |
| parent | c7fc2a931716e3d63ad6af648a3c18a658ae3c40 (diff) | |
Buffer: fix corner case in insert
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index 62cefef7..ac54f177 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -273,8 +273,10 @@ void Buffer::insert(const BufferIterator& pos, const String& content) } if (start == 0) line_it = m_lines.insert(line_it, { offset + start - (int)prefix.length(), prefix + content + suffix }); - else + else if (start != content.length() or not suffix.empty()) line_it = m_lines.insert(line_it, { offset + start, content.substr(start) + suffix }); + else + --line_it; begin_it = pos; end_it = BufferIterator(*this, { int(line_it - m_lines.begin()), int(line_it->length() - suffix.length()) }); |
