[vim/vim] "zb" scrolls incorrectly with cursor just above fold (PR #20923)

zeertzjq (Vim Github Repository) <[email protected]> Sun, 02 Aug 2026 15:59:20 -0700
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/pull/[email protected]>

----==_mimepart_6a6fcbc85aaf4_be116076757b
Content-Type: text/plain; charset="UTF-8"

Problem:  "zb" scrolls incorrectly with cursor just above fold.
Solution: Handle boff.lnum being set to the last line of a fold.

With the cursor just above fold, botline_forw() moves boff.lnum to the
last line of the fold, but curwin->w_botline is at the first line of the
fold, so the boff.lnum == curwin->w_botline condition never holds.

Instead, check that boff.lnum has just moved to or past w_botline by
comparing its previous value with w_botline.

Also make a similar change to the loff.lnum check above for symmetry.
That one doesn't change behavior, as topline_back() sets loff.lnum to
the first line of a fold.

related: neovim/neovim#41122

You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20923

-- Commit Summary --

  * "zb" scrolls incorrectly with cursor just above fold

-- File Changes --

    M src/move.c (14)
    M src/testdir/test_normal.vim (9)

-- Patch Links --

https://github.com/vim/vim/pull/20923.patch
https://github.com/vim/vim/pull/20923.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/20923
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/pull/[email protected]>

-- 
-- 
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/vim/vim/pull/20923%40github.com.

----==_mimepart_6a6fcbc85aaf4_be116076757b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<p dir=3D"auto">Problem:  "zb" scrolls incorrectly with cursor just above f=
old.<br>
Solution: Handle boff.lnum being set to the last line of a fold.</p>
<p dir=3D"auto">With the cursor just above fold, botline_forw() moves boff.=
lnum to the<br>
last line of the fold, but curwin-&gt;w_botline is at the first line of the=
<br>
fold, so the boff.lnum =3D=3D curwin-&gt;w_botline condition never holds.</=
p>
<p dir=3D"auto">Instead, check that boff.lnum has just moved to or past w_b=
otline by<br>
comparing its previous value with w_botline.</p>
<p dir=3D"auto">Also make a similar change to the loff.lnum check above for=
 symmetry.<br>
That one doesn't change behavior, as topline_back() sets loff.lnum to<br>
the first line of a fold.</p>
<p dir=3D"auto">related: <a class=3D"issue-link js-issue-link" data-error-t=
ext=3D"Failed to load title" data-id=3D"5044710822" data-permission-text=3D=
"Title is private" data-url=3D"https://github.com/neovim/neovim/issues/4112=
2" data-hovercard-type=3D"issue" data-hovercard-url=3D"/neovim/neovim/issue=
s/41122/hovercard" href=3D"https://github.com/neovim/neovim/issues/41122">n=
eovim/neovim#41122</a></p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>&nbsp;&nbsp;<a href=3D'https://github.com/vim/vim/pull/20923'>https://gi=
thub.com/vim/vim/pull/20923</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href=3D"https://github.com/vim/vim/pull/20923/commits/a21331005824=
faa4f62eff42c613179d831dbe46" class=3D"commit-link">a213310</a>  &quot;zb&q=
uot; scrolls incorrectly with cursor just above fold</li>
</ul>

<h4 style=3D"display: inline-block">File Changes </h4> <p style=3D"display:=
 inline-block">(<a href=3D"https://github.com/vim/vim/pull/20923/files">2&n=
bsp;files</a>)</p>
<ul>
  <li>
    <strong>M</strong>
    <a href=3D"https://github.com/vim/vim/pull/20923/files#diff-a3ba5fb329c=
14069f6d815e17db0ac6144cc42aca71effe59d026ddc9278d800">src/move.c</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href=3D"https://github.com/vim/vim/pull/20923/files#diff-9d84b9caecd=
293009a86907b62de40871b7f22bc478d2b237dc3ca6bb863924b">src/testdir/test_nor=
mal.vim</a>
    (9)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href=3D'https://github.com/vim/vim/pull/20923.patch'>https://githu=
b.com/vim/vim/pull/20923.patch</a></li>
  <li><a href=3D'https://github.com/vim/vim/pull/20923.diff'>https://github=
.com/vim/vim/pull/20923.diff</a></li>
</ul>

<p style=3D"font-size:small;-webkit-text-size-adjust:none;color:#666;">&mda=
sh;<br />Reply to this email directly, <a href=3D"https://github.com/vim/vi=
m/pull/20923">view it on GitHub</a>, or <a href=3D"https://github.com/notif=
ications/unsubscribe-auth/ACY5DGAWLW3WLHA2QA3TWJT5H7BURAVCNFSNUABEKJSXA33TN=
F2G64TZHM2DAOJZG42DQMR3JFZXG5LFHM2TANBUHA3TQOJUGSQXMAQ">unsubscribe</a>.<br=
 />Triage notifications, keep track of coding agent tasks and review pull r=
equests on the go with GitHub Mobile for <a href=3D"https://github.com/noti=
fications/mobile/ios/ACY5DGHRRDVS447I7LEPY3D5H7BURA5CNFSNUABEM5UWIORPF5TWS5=
BNNB2WEL2QOVWGYUTFOF2WK43UF42DCOJQGE4TCNRVGKTHEZLBONXW5KTTOVRHGY3SNFRGKZFFM=
V3GK3TUVJTG633UMVZF62LPOM">iOS</a> and <a href=3D"https://github.com/notifi=
cations/mobile/android/ACY5DGAHEW3HO6J4KOJFXMT5H7BURA5CNFSNUABEM5UWIORPF5TW=
S5BNNB2WEL2QOVWGYUTFOF2WK43UF42DCOJQGE4TCNRVGKTHEZLBONXW5KTTOVRHGY3SNFRGKZF=
FMV3GK3TUVZTG633UMVZF6YLOMRZG62LE">Android</a>. Download it today!
<br />You are receiving this because you are subscribed to this thread.<img=
 src=3D"https://github.com/notifications/beacon/ACY5DGDQNNL33YMQKGJX4ZD5H7B=
URBFCNFSM6AAAAAC4XLSC52WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHQAA=
AAAEWLFPTAUZZGKYLTN5XKU43VMJZWG4TJMJSWI.gif" height=3D"1" width=3D"1" alt=
=3D"" /><span style=3D"color: transparent; font-size: 0; display: none; vis=
ibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-wid=
th: 0; max-height: 0; mso-hide: all">Message ID: <span>&lt;vim/vim/pull/209=
23</span><span>@</span><span>github</span><span>.</span><span>com&gt;</span=
></span></p>
<script type=3D"application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/vim/vim/pull/20923",
"url": "https://github.com/vim/vim/pull/20923",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>

<p></p>

-- <br />
-- <br />
You received this message from the &quot;vim_dev&quot; maillist.<br />
Do not top-post! Type your reply below the text you are replying to.<br />
For more information, visit <a href=3D"http://www.vim.org/maillist.php">htt=
p://www.vim.org/maillist.php</a><br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;vim_dev&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">vim_dev+uns=
[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
vim_dev/vim/vim/pull/20923%40github.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/20923%40github.=
com</a>.<br />

----==_mimepart_6a6fcbc85aaf4_be116076757b--