From: zeertzjq Date: Sun, 22 Mar 2026 15:49:59 +0000 (+0000) Subject: patch 9.2.0222: "zb" scrolls incorrectly with cursor on fold X-Git-Tag: v9.2.0222^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a3b75d67b98777b319eb9c4e5e0d7a130aaec5e;p=thirdparty%2Fvim.git patch 9.2.0222: "zb" scrolls incorrectly with cursor on fold Problem: "zb" scrolls incorrectly with cursor on fold. Solution: Set w_botline to the line below the fold (zeertzjq). related: neovim/neovim#38413 closes: #19785 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- diff --git a/src/move.c b/src/move.c index 2bf8c2b74a..ebc8853617 100644 --- a/src/move.c +++ b/src/move.c @@ -2570,8 +2570,12 @@ scroll_cursor_bot(int min_scroll, int set_topbot) if (set_topbot) { used = 0; - curwin->w_botline = cln + 1; - loff.lnum = cln + 1; + linenr_T cln_last = cln; +#ifdef FEAT_FOLDING + (void)hasFolding(cln, NULL, &cln_last); +#endif + curwin->w_botline = cln_last + 1; + loff.lnum = cln_last + 1; #ifdef FEAT_DIFF loff.fill = 0; #endif diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 20adb24b1e..4f353c5b8c 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -4269,6 +4269,20 @@ func Test_single_line_filler_zb() bw! endfunc +" Test for zb with fewer buffer lines than window height, non-zero 'scrolloff' +" and cursor on fold. +func Test_zb_with_cursor_on_fold() + 15new + call setline(1, range(1, 5) + ['', 'foo{{{', 'bar}}}', '', 'baz']) + setlocal foldmethod=marker scrolloff=1 + call assert_equal(8, foldclosedend(7)) + call cursor(7, 1) + normal! zb + call assert_equal(1, line('w0')) + + bwipe! +endfunc + " Test for Ctrl-U not getting stuck at end of buffer with 'scrolloff'. func Test_halfpage_scrolloff_eob() set scrolloff=5 diff --git a/src/version.c b/src/version.c index 9f578f20e2..ca65857756 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 222, /**/ 221, /**/