From 08529fc11599160b41694b7726a343ab14c75645 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 15 Jan 2017 21:44:57 -0500 Subject: [PATCH] keep cursors off newlines after applying change operations when not in insert mode --- src/core/Buffer.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/Buffer.cc b/src/core/Buffer.cc index be08f6d..53906df 100644 --- a/src/core/Buffer.cc +++ b/src/core/Buffer.cc @@ -241,11 +241,18 @@ size_t Buffer::lines_in_data(size_t offset, size_t length) void Buffer::post_warp_cursors() { - for (auto cursor : m_cursors) + if (size() > 0u) { - if ((*cursor == *m_eof_iterator) && (size() > 0u)) + for (auto cursor : m_cursors) { - cursor->go_back(); + if (*cursor == *m_eof_iterator) + { + cursor->go_back(); + } + if ((!insert_mode()) && (**cursor == '\n')) + { + cursor->go_left_in_line(); + } } } }