aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ops.c7
-rw-r--r--src/nvim/testdir/test_put.vim12
2 files changed, 17 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 83e2a85112..6e6f478166 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -3696,8 +3696,11 @@ error:
len = STRLEN(y_array[y_size - 1]);
col = (colnr_T)len - lendiff;
if (col > 1) {
- curbuf->b_op_end.col = col - 1 - utf_head_off(y_array[y_size - 1],
- y_array[y_size - 1] + len - 1);
+ curbuf->b_op_end.col = col - 1;
+ if (len > 0) {
+ curbuf->b_op_end.col -= utf_head_off(y_array[y_size - 1],
+ y_array[y_size - 1] + len - 1);
+ }
} else {
curbuf->b_op_end.col = 0;
}
diff --git a/src/nvim/testdir/test_put.vim b/src/nvim/testdir/test_put.vim
index 65232175c6..ffdaa81e0b 100644
--- a/src/nvim/testdir/test_put.vim
+++ b/src/nvim/testdir/test_put.vim
@@ -203,3 +203,15 @@ func Test_multibyte_op_end_mark()
call assert_equal([0, 2, 7, 0], getpos("']"))
bwipe!
endfunc
+
+" this was putting a mark before the start of a line
+func Test_put_empty_register()
+ new
+ norm yy
+ norm [Pi00ggv)s0
+ sil! norm [P
+ bwipe!
+endfunc
+
+
+" vim: shiftwidth=2 sts=2 expandtab