vim-patch:9.2.0222: "zb" scrolls incorrectly with cursor on fold (#38423)

Problem:  "zb" scrolls incorrectly with cursor on fold.
Solution: Set w_botline to the line below the fold (zeertzjq).

related: neovim/neovim#38413
closes:  vim/vim#19785

5a3b75d67b
This commit is contained in:
zeertzjq
2026-03-23 07:12:08 +08:00
committed by GitHub
parent 471213ee61
commit 11b9ec38d2
2 changed files with 18 additions and 2 deletions

View File

@@ -1923,8 +1923,10 @@ void scroll_cursor_bot(win_T *wp, int min_scroll, bool set_topbot)
if (set_topbot) {
int used = 0;
wp->w_botline = cln + 1;
loff.lnum = cln + 1;
linenr_T cln_last = cln;
hasFolding(wp, cln, NULL, &cln_last);
wp->w_botline = cln_last + 1;
loff.lnum = cln_last + 1;
loff.fill = 0;
while (true) {
topline_back_winheight(wp, &loff, false);

View File

@@ -4282,6 +4282,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