aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKillTheMule <KillTheMule@users.noreply.github.com>2020-09-30 21:28:21 +0200
committerKillTheMule <KillTheMule@users.noreply.github.com>2020-09-30 21:28:21 +0200
commit02dcc3c11ad72e0ae3c6704af6b08d9275ed5470 (patch)
tree439ad79a0ec632c7ac8b4e40bf0d05169ffecfcd
parentc1a740ae339c0d4de79ad5b82d540a671bd90505 (diff)
downloadrneovim-02dcc3c11ad72e0ae3c6704af6b08d9275ed5470.tar.gz
rneovim-02dcc3c11ad72e0ae3c6704af6b08d9275ed5470.tar.bz2
rneovim-02dcc3c11ad72e0ae3c6704af6b08d9275ed5470.zip
Fix byte updates for blockwise paste at buffer end
-rw-r--r--src/nvim/ops.c6
-rw-r--r--test/functional/lua/buffer_updates_spec.lua4
2 files changed, 7 insertions, 3 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 6459dbfe6e..8329daf5f1 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -3109,6 +3109,9 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
for (i = 0; i < y_size; i++) {
int spaces;
char shortline;
+ // can just be 0 or 1, needed for blockwise paste beyond the current
+ // buffer end
+ int lines_appended = 0;
bd.startspaces = 0;
bd.endspaces = 0;
@@ -3122,6 +3125,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
break;
}
nr_lines++;
+ lines_appended = 1;
}
/* get the old line and advance to the position to insert at */
oldp = get_cursor_line_ptr();
@@ -3194,7 +3198,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
memmove(ptr, oldp + bd.textcol + delcount, (size_t)columns);
ml_replace(curwin->w_cursor.lnum, newp, false);
extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum-1, bd.textcol,
- delcount, (int)totlen, kExtmarkUndo);
+ delcount, (int)totlen + lines_appended, kExtmarkUndo);
++curwin->w_cursor.lnum;
if (i == 0)
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 2a1ad210c1..fa31880782 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -486,8 +486,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
feed('p')
check_events {
{ "test1", "bytes", 1, 3, 2, 1, 5, 0, 0, 0, 0, 1, 1 };
- { "test1", "bytes", 1, 3, 3, 0, 7, 0, 0, 0, 0, 2, 2 };
- { "test1", "bytes", 1, 3, 4, 0, 10, 0, 0, 0, 0, 2, 2 };
+ { "test1", "bytes", 1, 3, 3, 0, 7, 0, 0, 0, 0, 3, 3 };
+ { "test1", "bytes", 1, 3, 4, 0, 10, 0, 0, 0, 0, 3, 3 };
}
feed('2G0')