[vim/vim] scroll: 'smoothscroll' position is lost when splitting a window (PR #20912)
h_east (Vim Github Repository) <[email protected]> Sat, 01 Aug 2026 08:44:18 -0700
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <vim/vim/pull/[email protected]> |
----==_mimepart_6a6e14526a8f6_cb116025057de
Content-Type: text/plain; charset="UTF-8"
```
Problem: With 'smoothscroll' the position in a long line is lost when a
window is split and closed again.
Solution: With 'splitkeep' "screen" keep the skipped columns, they are part
of keeping the same screen lines. Otherwise put the cursor in the
row that keeps its relative position, instead of the last row.
```
---
This was in todo.txt, the entry is removed.
With 'smoothscroll' and a line longer than the window, ":split" followed by
":close" moved the view back by several screen lines. With a window of 23
lines and 'columns' 80, the skipped columns went from 800 to 160.
For 'splitkeep' "screen" win_fix_scroll() keeps the same screen lines by
moving the cursor to the last line and scrolling to it; that recomputes the
skipped columns for a position which is not where the cursor is. The cursor
is put back afterwards, now the skipped columns are as well, when the topline
did not change. The position is now kept exactly.
For 'splitkeep' "cursor" scroll_to_fraction() put the cursor in the last row
of the window when the cursor line does not fit, instead of the row that
keeps its relative position. With the example above the skipped columns are
now 880 instead of 160; the remaining difference of one screen line is the
resolution of the fraction.
The second change also applies without 'smoothscroll', where the skipped
columns are used to keep the cursor visible in a line that is longer than
the window.
You can view, comment on, or merge this pull request online at:
https://github.com/vim/vim/pull/20912
-- Commit Summary --
* scroll: 'smoothscroll' position is lost when splitting a window
-- File Changes --
M runtime/doc/todo.txt (3)
M src/testdir/test_window_cmd.vim (19)
M src/window.c (12)
-- Patch Links --
https://github.com/vim/vim/pull/20912.patch
https://github.com/vim/vim/pull/20912.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/20912
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/20912%40github.com.
----==_mimepart_6a6e14526a8f6_cb116025057de
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<pre class=3D"notranslate"><code class=3D"notranslate">Problem: With 'smoo=
thscroll' the position in a long line is lost when a
window is split and closed again.
Solution: With 'splitkeep' "screen" keep the skipped columns, they are part
of keeping the same screen lines. Otherwise put the cursor in th=
e
row that keeps its relative position, instead of the last row.
</code></pre>
<hr>
<p dir=3D"auto">This was in todo.txt, the entry is removed.</p>
<p dir=3D"auto">With 'smoothscroll' and a line longer than the window, ":sp=
lit" followed by<br>
":close" moved the view back by several screen lines. With a window of 23<=
br>
lines and 'columns' 80, the skipped columns went from 800 to 160.</p>
<p dir=3D"auto">For 'splitkeep' "screen" win_fix_scroll() keeps the same sc=
reen lines by<br>
moving the cursor to the last line and scrolling to it; that recomputes the=
<br>
skipped columns for a position which is not where the cursor is. The curso=
r<br>
is put back afterwards, now the skipped columns are as well, when the topli=
ne<br>
did not change. The position is now kept exactly.</p>
<p dir=3D"auto">For 'splitkeep' "cursor" scroll_to_fraction() put the curso=
r in the last row<br>
of the window when the cursor line does not fit, instead of the row that<br=
>
keeps its relative position. With the example above the skipped columns ar=
e<br>
now 880 instead of 160; the remaining difference of one screen line is the<=
br>
resolution of the fraction.</p>
<p dir=3D"auto">The second change also applies without 'smoothscroll', wher=
e the skipped<br>
columns are used to keep the cursor visible in a line that is longer than<b=
r>
the window.</p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href=3D'https://github.com/vim/vim/pull/20912'>https://gi=
thub.com/vim/vim/pull/20912</a></p>
<h4>Commit Summary</h4>
<ul>
<li><a href=3D"https://github.com/vim/vim/pull/20912/commits/540defd19fb0=
d6892c181ee65a40e13d4c54ff96" class=3D"commit-link">540defd</a> scroll: &#=
39;smoothscroll' position is lost when splitting a window</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/20912/files">3&n=
bsp;files</a>)</p>
<ul>
<li>
<strong>M</strong>
<a href=3D"https://github.com/vim/vim/pull/20912/files#diff-fb7eed53e3f=
2993f9d82c748206eaca82fd1d054a417c6de477bb54373d85643">runtime/doc/todo.txt=
</a>
(3)
</li>
<li>
<strong>M</strong>
<a href=3D"https://github.com/vim/vim/pull/20912/files#diff-7227b946118=
670c188b2d8128335efa187ec02b1bea16142a40daee95cc14303">src/testdir/test_win=
dow_cmd.vim</a>
(19)
</li>
<li>
<strong>M</strong>
<a href=3D"https://github.com/vim/vim/pull/20912/files#diff-fda32749053=
739202f20c8b223315aba489c8d8f5b7ef99960f6791263accf30">src/window.c</a>
(12)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href=3D'https://github.com/vim/vim/pull/20912.patch'>https://githu=
b.com/vim/vim/pull/20912.patch</a></li>
<li><a href=3D'https://github.com/vim/vim/pull/20912.diff'>https://github=
.com/vim/vim/pull/20912.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/20912">view it on GitHub</a>, or <a href=3D"https://github.com/notif=
ications/unsubscribe-auth/ACY5DGCAU222BEITOAPUQJ35HYF5FAVCNFSNUABEKJSXA33TN=
F2G64TZHM2DAOJZG42DQMR3JFZXG5LFHM2TAMZXG4ZTQNBQHCQXMAQ">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/ACY5DGGZIW7W2PEDTV3GBGD5HYF5FA5CNFSNUABEM5UWIORPF5TWS5=
BNNB2WEL2QOVWGYUTFOF2WK43UF42DCOBUGQZTSMZUG2THEZLBONXW5KTTOVRHGY3SNFRGKZFFM=
V3GK3TUVJTG633UMVZF62LPOM">iOS</a> and <a href=3D"https://github.com/notifi=
cations/mobile/android/ACY5DGBEZOTQVHHXJU42M6T5HYF5FA5CNFSNUABEM5UWIORPF5TW=
S5BNNB2WEL2QOVWGYUTFOF2WK43UF42DCOBUGQZTSMZUG2THEZLBONXW5KTTOVRHGY3SNFRGKZF=
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/ACY5DGBX4372JXAIEAILBQ35HYF=
5FBFCNFSM6AAAAAC4VYH3UCWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHQAA=
AAAEWELSNIUZZGKYLTN5XKU43VMJZWG4TJMJSWI.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><vim/vim/pull/209=
12</span><span>@</span><span>github</span><span>.</span><span>com></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/20912",
"url": "https://github.com/vim/vim/pull/20912",
"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 "vim_dev" 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" 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/20912%40github.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/20912%40github.=
com</a>.<br />
----==_mimepart_6a6e14526a8f6_cb116025057de--