aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/change.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/change.c')
-rw-r--r--src/nvim/change.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 4ac5edeaa9..2450c56838 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -413,7 +413,11 @@ void deleted_lines(linenr_T lnum, long count)
/// be triggered to display the cursor.
void deleted_lines_mark(linenr_T lnum, long count)
{
- mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM, -count,
+ // if we deleted the entire buffer, we need to implicity add a new empty line
+ bool made_empty = (count > 0) && curbuf->b_ml.ml_flags & ML_EMPTY;
+
+ mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM,
+ -count + (made_empty?1:0),
kExtmarkUndo);
changed_lines(lnum, 0, lnum + count, -count, true);
}
@@ -625,7 +629,7 @@ void ins_char_bytes(char_u *buf, size_t charlen)
// Copy bytes before the cursor.
if (col > 0) {
- memmove(newp, oldp, (size_t)col);
+ memmove(newp, oldp, col);
}
// Copy bytes after the changed character(s).