neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 69cd0ba27bfc595b643cde0d9f1156ee144dee4a
parent 37af46bb4c351c69376f9c2947b7c3862014ee41
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu, 30 Jun 2022 20:16:00 +0800

vim-patch:9.0.0011: reading beyond the end of the line with put command (#19166)

Problem:    Reading beyond the end of the line with put command.
Solution:   Adjust the end mark position.
https://github.com/vim/vim/commit/d25f003342aca9889067f2e839963dfeccf1fe05
Diffstat:
Msrc/nvim/ops.c | 5++---
Msrc/nvim/testdir/test_put.vim | 12++++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/nvim/ops.c b/src/nvim/ops.c @@ -3344,7 +3344,6 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) totlen = (size_t)(count * (yanklen + spaces) + bd.startspaces + bd.endspaces); - int addcount = (int)totlen + lines_appended; newp = (char_u *)xmalloc(totlen + oldlen + 1); // copy part up to cursor to new line @@ -3366,7 +3365,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) memset(ptr, ' ', (size_t)spaces); ptr += spaces; } else { - addcount -= spaces; + totlen -= (size_t)spaces; // didn't use these spaces } } @@ -3380,7 +3379,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, (char *)newp, false); extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, bd.textcol, - delcount, addcount, kExtmarkUndo); + delcount, (int)totlen + lines_appended, kExtmarkUndo); ++curwin->w_cursor.lnum; if (i == 0) { diff --git a/src/nvim/testdir/test_put.vim b/src/nvim/testdir/test_put.vim @@ -213,5 +213,17 @@ func Test_put_empty_register() bwipe! endfunc +" this was putting the end mark after the end of the line +func Test_put_visual_mode() + edit! SomeNewBuffer + set selection=exclusive + exe "norm o\t" + m0 + sil! norm pp + + bwipe! + set selection& +endfunc + " vim: shiftwidth=2 sts=2 expandtab