patch 9.2.0222: "zb" scrolls incorrectly with cursor on fold

Commit: 
https://github.com/vim/vim/commit/5a3b75d67b98777b319eb9c4e5e0d7a130aaec5e
Author: zeertzjq <[email protected]>
Date:   Sun Mar 22 15:49:59 2026 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/move.c b/src/move.c
index 2bf8c2b74..ebc885361 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 20adb24b1..4f353c5b8 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 9f578f20e..ca6585775 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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1w4LDh-000eCF-IS%40256bit.org.

Raspunde prin e-mail lui