]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.2.0262: invalid lnum when pasting text copied blockwise v9.2.0262
authorPierluigi Lenoci <pierluigi.lenoci@gmail.com>
Fri, 27 Mar 2026 15:49:27 +0000 (15:49 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 27 Mar 2026 15:49:27 +0000 (15:49 +0000)
commit80a0c355cff08bc8a20d548cc1e62a11a978babb
tree0b987406c30cb1dc3b8c83af43ea5780869c80dd
parent54b6c0c0e7191105c80987297bd0e1ad2bc009dc
patch 9.2.0262: invalid lnum when pasting text copied blockwise

Problem:  invalid lnum when pasting text copied blockwise
          (KillTheMule)
Solution: Subtract nr_lines from curwin->w_cursor.lnum when calling
          changed_lines() in do_put() (Pierluigi Lenoci)

When doing a blockwise paste beyond the end of the buffer, new lines are
appended and nr_lines is incremented accordingly. However, the
changed_lines() call used curwin->w_cursor.lnum as the "lnume" argument
(the first line below the changed lines BEFORE the change), which is
incorrect because the cursor has already been moved past the newly
appended lines.

Fix by subtracting nr_lines from curwin->w_cursor.lnum, so that lnume
correctly reflects the state before the change, as documented in
changed_lines().

Add a listener test to verify the correct values are reported.

Port of neovim/neovim#12733.

fixes:  #6660
closes: #19844

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/register.c
src/testdir/test_listener.vim
src/version.c