summaryrefslogtreecommitdiff
path: root/src/selection.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/selection.cc')
-rw-r--r--src/selection.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/selection.cc b/src/selection.cc
index a9623a73..d5f72eb3 100644
--- a/src/selection.cc
+++ b/src/selection.cc
@@ -443,7 +443,11 @@ BufferIterator prepare_insert(Buffer& buffer, const Selection& sel, InsertMode m
case InsertMode::Replace:
return erase(buffer, sel);
case InsertMode::Append:
- return utf8::next(buffer.iterator_at(sel.max()), buffer.end());
+ {
+ // special case for end of lines, append to current line instead
+ auto pos = buffer.iterator_at(sel.max());
+ return *pos == '\n' ? pos : utf8::next(pos, buffer.end());
+ }
case InsertMode::InsertAtLineBegin:
return buffer.iterator_at(sel.min().line);
case InsertMode::AppendAtLineEnd: