[vim/vim] Changed_lines in blockwise paste (#6660)

33 views
Skip to first unread message

KillTheMule

unread,
Aug 8, 2020, 3:18:58 PM8/8/20
to vim/vim, Subscribed

Hey,

we've recently had this bug report in neovim. I've worked out a solution here, which I wanted to bring to your attention, since it concerns code shared between vim and neovim.

As written in the issue, I don't think it's a bug in vim, but rather a misleading comment: The comment of changed_lines says

"lnume" the first line below the changed lines (BEFORE the change)

while in this specific instance (blockwise paste at the end of the buffer) it gets called with a number larger than that. It does not seem to be a problem, since I think changed_lines in vim only registers the lines for redrawing, and that is robust against putting in too large numbers. It manifests as a bug in neovim since we're using changed_lines to read those lines from the buffer, so we really need the exactly right number here.

So, maybe you want to straighten that out in vim's code as well. Any comments on the validity of my fix or analysis are very welcome, too, of course :)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Bram Moolenaar

unread,
Aug 8, 2020, 5:01:10 PM8/8/20
to vim/vim, Subscribed


> we've recently had [this](https://github.com/neovim/neovim/issues/12718) bug report in neovim. I've worked out a solution [here](https://github.com/neovim/neovim/pull/12733), which I wanted to bring to your attention, since it concerns code shared between vim and neovim.

>
> As written in the issue, I don't think it's a bug in vim, but rather a misleading comment: The comment of `changed_lines` says
>
> >"lnume" the first line below the changed lines (BEFORE the change)
>
> while in this specific instance (blockwise paste at the end of the buffer) it gets called with a number larger than that. It does not seem to be a problem, since I think `changed_lines` in vim only registers the lines for redrawing, and that is robust against putting in too large numbers. It manifests as a bug in neovim since we're using `changed_lines` to read those lines from the buffer, so we really need the exactly right number here.
>
> So, maybe you want to straighten that out in vim's code as well. Any comments on the validity of my fix or analysis are very welcome, too, of course :)

Thanks for linking to the patch.

I wonder, does it work to do:

changed_lines(lnum, 0, curwin->w_cursor.lnum - nr_lines, nr_lines);

It's a bit simpler.


Not sure if we can add a test in Vim. Perhaps with a listener.

--
hundred-and-one symptoms of being an internet addict:
159. You get excited whenever discussing your hard drive.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

KillTheMule

unread,
Aug 9, 2020, 2:45:44 PM8/9/20
to vim/vim, Subscribed

I wonder, does it work to do:

changed_lines(lnum, 0, curwin->w_cursor.lnum - nr_lines, nr_lines);

It's a bit simpler.

That would work out it before the paste curwin->w_cursor.lnum is the same as curbuf->b_op_start.lnum. Is that a reasonable assumption? I thought about :put, but that's always linewise, but might there be other cases? Otoh, the cursor is always moved down y_size lines, so the code does some to assume this anyways.

Jaehwang Jerry Jung

unread,
Aug 23, 2020, 9:06:26 AM8/23/20
to vim/vim, Subscribed

ping?

Bram Moolenaar

unread,
Sep 30, 2020, 4:56:19 PM9/30/20
to vim/vim, Subscribed

Can someone turn this into a pull request?

Aditya Malik

unread,
Aug 5, 2025, 6:01:57 AM8/5/25
to vim/vim, Subscribed
alarcritty left a comment (vim/vim#6660)

Hi @KillTheMule I'd like to work on this issue. Is it still open?"


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6660/3154494004@github.com>

KillTheMule

unread,
Aug 5, 2025, 4:07:05 PM8/5/25
to vim/vim, Subscribed
KillTheMule left a comment (vim/vim#6660)

I only fixed it on the neovim side, not sure what the status is at vim's side.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6660/3156477228@github.com>

Aditya Malik

unread,
Aug 6, 2025, 12:41:52 AM8/6/25
to vim/vim, Subscribed
alarcritty left a comment (vim/vim#6660)

oh okay , no problem .


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6660/3157381063@github.com>

Christian Brabandt

unread,
Aug 6, 2025, 3:43:31 PM8/6/25
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#6660)

So you should be able to take the Neovim patch and port it to Vim if you want to contribute.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6660/3161371091@github.com>

Aditya Malik

unread,
Aug 7, 2025, 2:13:04 AM8/7/25
to vim/vim, Subscribed
alarcritty left a comment (vim/vim#6660)

okay for sure i'll try that .


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6660/3162647164@github.com>

Christian Brabandt

unread,
Mar 27, 2026, 11:56:48 AM (17 hours ago) Mar 27
to vim/vim, Subscribed

Closed #6660 as completed via 80a0c35.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/6660/issue_event/23977221813@github.com>

Reply all
Reply to author
Forward
0 new messages