summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/input_handler.cc1
-rw-r--r--src/selection.cc6
2 files changed, 6 insertions, 1 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 4cc6d5ee..975e457b 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -1016,6 +1016,7 @@ private:
if (m_insert_mode == InsertMode::Append and sel.cursor().column > 0)
sel.cursor() = context().buffer().char_prev(sel.cursor());
}
+ selections.avoid_eol();
if (m_disable_hooks)
context().user_hooks_support().enable();
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: