Skip to content

Fix smoothscroll to work with zz/zt/zb#11764

Closed
ychin wants to merge 1 commit intovim:masterfrom
ychin:smoothscroll-zz-zb-fixes
Closed

Fix smoothscroll to work with zz/zt/zb#11764
ychin wants to merge 1 commit intovim:masterfrom
ychin:smoothscroll-zz-zb-fixes

Conversation

@ychin
Copy link
Contributor

@ychin ychin commented Dec 31, 2022

This commit does two things:


First, existing zt/zb/zz implementation is buggy when 'smoothscroll' are 'wrap' are set. They can lead to inconsistency bugs with regarding to repainting and cursor states.

For zz, if the user uses zz whenever the top line is smooth-scrolled, the resulting draw will be wrong. For zt, if the line above the current line is super long (meaning it is so long that the wrapped line covers more than the entire screen), it will lead to the cursor being in a bad state. For zb, the exact conditions are harder to reproduce, but basically it triggers when the top line is smooth scrolled, and second line is more than one physical line tall.

Most of the reasons why they are broken is because reset_skipcol() or redraw_later() aren't called in the right place, so this change will make sure to call them appropriately.


Second, zb/zz currently will not utilize 'smoothscroll' in a satisfactory fashion. If 'smoothscroll'/'wrap' are set, we should be able to accurate put the current line at the bottom/middle of the screen by smooth-scrolling a long wrapped line at the top of the screen. This change will make those two commands do that.


Also, add tests to regression test these features.

This commit does two things:

---

First, existing zt/zb/zz implementation is buggy when 'smoothscroll' are
'wrap' are set. They can lead to inconsistency bugs with regarding to
repainting and cursor states.

For zz, if the user uses `zz` whenever the top line is smooth-scrolled,
the resulting draw will be wrong. For zt, if the line above the current
line is super long (meaning it is so long that the wrapped line covers
more than the entire screen), it will lead to the cursor being in a bad
state. For zb, the exact conditions are harder to reproduce, but
basically it triggers when the top line is smooth scrolled, and second
line is more than one physical line tall.

Most of the reasons why they are broken is because `reset_skipcol()` or
`redraw_later()` aren't called in the right place, so this change will
make sure to call them appropriately.

---

Second, zb/zz currently will not utilize 'smoothscroll' in a
satisfactory fashion. If 'smoothscroll'/'wrap' are set, we should be
able to accurate put the current line at the bottom/middle of the screen
by smooth-scrolling a long wrapped line at the top of the screen. This
change will make those two commands do that.

---

Also, add tests to regression test these features.
@ychin
Copy link
Contributor Author

ychin commented Dec 31, 2022

For the first point (inconsistency bugs), see the following asciicast which demos how to trigger them.

asciicast

@ychin
Copy link
Contributor Author

ychin commented Dec 31, 2022

Also, I think scrolloff is currently not working perfectly when smoothscroll is set. The logic is not taking smoothscroll into account and it also doesn't handle super long lines (lines that cannot be shown in its entirely on the screen). I decided not to tackle them for now as I don't think they lead to any serious bugs, just that it would scroll a little more than necessary.

Ideally, when we have smoothscroll, scrolloff can be more precise in always just showing that many physical lines for zt and zb (actually, for zb, we don't even need smoothscroll since we can show partial lines depending on the display setting).

@codecov
Copy link

codecov bot commented Dec 31, 2022

Codecov Report

Merging #11764 (0a63ed6) into master (7b8db11) will increase coverage by 0.00%.
The diff coverage is 82.19%.

@@           Coverage Diff           @@
##           master   #11764   +/-   ##
=======================================
  Coverage   81.90%   81.91%           
=======================================
  Files         164      164           
  Lines      191923   191986   +63     
  Branches    43556    43569   +13     
=======================================
+ Hits       157201   157269   +68     
+ Misses      21974    21962   -12     
- Partials    12748    12755    +7     
Flag Coverage Δ
huge-clang-none 82.62% <82.19%> (+<0.01%) ⬆️
huge-gcc-none 54.19% <70.42%> (+0.01%) ⬆️
huge-gcc-testgui 52.65% <70.42%> (+<0.01%) ⬆️
huge-gcc-unittests 0.29% <0.00%> (-0.01%) ⬇️
linux 82.42% <82.19%> (+<0.01%) ⬆️
mingw-x64-HUGE 76.44% <34.00%> (-0.02%) ⬇️
mingw-x86-HUGE 76.95% <34.00%> (-0.02%) ⬇️
windows 78.05% <34.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/move.c 91.04% <82.19%> (-0.44%) ⬇️
src/gui_gtk_x11.c 51.74% <0.00%> (-0.10%) ⬇️
src/buffer.c 87.14% <0.00%> (-0.08%) ⬇️
src/undo.c 75.82% <0.00%> (-0.07%) ⬇️
src/gui.c 72.66% <0.00%> (-0.05%) ⬇️
src/terminal.c 77.90% <0.00%> (-0.03%) ⬇️
src/channel.c 83.19% <0.00%> (+0.04%) ⬆️
src/netbeans.c 72.38% <0.00%> (+0.07%) ⬆️
src/misc2.c 89.57% <0.00%> (+0.09%) ⬆️
src/regexp_nfa.c 89.85% <0.00%> (+0.09%) ⬆️
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@brammool
Copy link
Contributor

brammool commented Dec 31, 2022 via email

@brammool brammool closed this in db4d88c Dec 31, 2022
@ychin ychin deleted the smoothscroll-zz-zb-fixes branch January 1, 2023 03:25
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 28, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 28, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 28, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 28, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
zeertzjq pushed a commit to luukvbaal/neovim that referenced this pull request Apr 28, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 28, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 29, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 29, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 29, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 29, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request Apr 30, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request May 1, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request May 2, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
luukvbaal added a commit to luukvbaal/neovim that referenced this pull request May 2, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
clason pushed a commit to clason/neovim that referenced this pull request May 10, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
tom-anders pushed a commit to tom-anders/neovim that referenced this pull request May 21, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
folke pushed a commit to folke/neovim that referenced this pull request May 22, 2023
…othscroll'

Problem:    Cursor positioning and display problems with 'smoothscroll' and
            using "zt", "zb" or "zz".
Solution:   Adjust computations and conditions. (Yee Cheng Chin,
            closes vim/vim#11764)

vim/vim@db4d88c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants