diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-03-16 13:48:11 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-03-16 13:48:11 +0000 |
| commit | de1433d30ade30c6768cefb085ff69ef7387fa2f (patch) | |
| tree | ce7161d346db680e96cb80ed22928810e45655c4 /src/buffer_utils.hh | |
| parent | c5b24e2a8a783fda939c6576158e0d9d591d632b (diff) | |
Avoid the spurious newline insertion when replacing at end of buffer
Add a Buffer::replace method to handle the replacements properly
Fixes #633
Diffstat (limited to 'src/buffer_utils.hh')
| -rw-r--r-- | src/buffer_utils.hh | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/buffer_utils.hh b/src/buffer_utils.hh index 543e2357..97c5374d 100644 --- a/src/buffer_utils.hh +++ b/src/buffer_utils.hh @@ -21,6 +21,13 @@ inline BufferIterator erase(Buffer& buffer, const Selection& range) buffer.iterator_at(buffer.char_next(range.max()))); } +inline BufferIterator replace(Buffer& buffer, const Selection& range, StringView content) +{ + return buffer.replace(buffer.iterator_at(range.min()), + buffer.iterator_at(buffer.char_next(range.max())), + content); +} + inline CharCount char_length(const Buffer& buffer, const Selection& range) { return utf8::distance(buffer.iterator_at(range.min()), |
