Skip to content

'splitscroll' test takes too long#11139

Closed
luukvbaal wants to merge 1 commit intovim:masterfrom
luukvbaal:splitscroll
Closed

'splitscroll' test takes too long#11139
luukvbaal wants to merge 1 commit intovim:masterfrom
luukvbaal:splitscroll

Conversation

@luukvbaal
Copy link
Contributor

@luukvbaal luukvbaal commented Sep 15, 2022

Problem: 'splitscroll' test takes too long. Cursor position is not always maintained when not in normal mode.
Solution: Get rid of nested for loops. Center cursor in window when not in normal mode.

I think this should test most of what we actually wanted to test with the nested loops. Tested option values generated by call add(v:errors, "so=".run.", tab=".(run % 5).", winbar=".(run % 2).", ls=".(run % 3).", ea=".(run % 2).", sb=".(run % 3).", pos=".pos):

so=0, tab=0, winbar=0, ls=0, ea=0, sb=0, pos=H
so=1, tab=1, winbar=1, ls=1, ea=1, sb=1, pos=M
so=2, tab=1, winbar=0, ls=2, ea=0, sb=1, pos=L
so=3, tab=1, winbar=1, ls=0, ea=1, sb=0, pos=H
so=4, tab=1, winbar=0, ls=1, ea=0, sb=1, pos=L
so=5, tab=0, winbar=1, ls=2, ea=1, sb=1, pos=M
so=6, tab=1, winbar=0, ls=0, ea=0, sb=0, pos=H
so=7, tab=1, winbar=1, ls=1, ea=1, sb=1, pos=M
so=8, tab=1, winbar=0, ls=2, ea=0, sb=1, pos=L
so=9, tab=1, winbar=1, ls=0, ea=1, sb=0, pos=H
so=10, tab=0, winbar=0, ls=1, ea=0, sb=1, pos=L

EDIT: investigating failing test.

@mityu
Copy link
Contributor

mityu commented Sep 15, 2022

I don't know why but it seems that test fails when window height is short.
At least in my environment, test fails when window height <= 30.

Here's the test results in my environment:

Terminal width x height Result
80x24 failed
80x30 failed
80x31 passed
80x35 passed
90x30 failed
90x31 passed

Environment:

  • OS: macOS Monterey
  • Terminal: iTerm2 3.4.16

@brammool
Copy link
Contributor

brammool commented Sep 15, 2022 via email

@luukvbaal
Copy link
Contributor Author

I don't know why but it seems that test fails when window height is short. At least in my environment, test fails when window height <= 30.

Yeah it has to do with the 'scrolloff' insert mode case. I think I have found the fix.

Most of the values are binary, but 'scrolloff' is a value. Now there is
only one test with 'scrolloff' set to zero.

Yeah you're right. Although 'scrolloff' is the more complicated case that could do with more testing, only doing a single run with 'so==0' might result in missing things.

@brammool
Copy link
Contributor

brammool commented Sep 15, 2022 via email

@luukvbaal
Copy link
Contributor Author

Yeah it has to do with the 'scrolloff' insert mode case. I think I have found the fix.

To reiterate: if the windows are resized while we are not in normal mode (e.g. by autocommands/plugins), we want to make sure the cursor position stays valid, rather than changing it. Currently we were doing scroll_to_fraction with w_fraction set to 0 or 1, depending if the cursor went out of view above or below the window, to scroll the minimal amount. This does not work properly when w_height < 'scrolloff'. The fix I propose is just scrolling the cursor to the middle of the window instead. This works for the w_height < 'scrolloff' case and does not seem too offensive otherwise, even assuming 'scrolloff == 0'. Since scrolling will happen anyways we might as well place the cursor in the middle of the screen if that is where you were typing/selecting.

@luukvbaal
Copy link
Contributor Author

luukvbaal commented Sep 15, 2022

Latest commit tests these values:

so=0, tab=0, winbar=0, ls=0, ea=0, sb=0, pos=H
so=1, tab=1, winbar=1, ls=1, ea=1, sb=1, pos=M
so=2, tab=1, winbar=0, ls=2, ea=0, sb=1, pos=L
so=0, tab=1, winbar=1, ls=0, ea=1, sb=0, pos=H
so=4, tab=1, winbar=0, ls=1, ea=0, sb=1, pos=L
so=5, tab=0, winbar=1, ls=2, ea=1, sb=1, pos=M
so=0, tab=1, winbar=0, ls=0, ea=0, sb=0, pos=H
so=7, tab=1, winbar=1, ls=1, ea=1, sb=1, pos=M
so=8, tab=1, winbar=0, ls=2, ea=0, sb=1, pos=L
so=0, tab=1, winbar=1, ls=0, ea=1, sb=0, pos=H
so=10, tab=0, winbar=0, ls=1, ea=0, sb=1, pos=L

Increasing run range to as far as 100 still passes the test so that makes me confident that 'scrolloff' is now handled correctly.

BTW: I can avoid the window resizing by using:

" disallow window resizing
let save_WS = &t_WS
set t_WS=

Should I add it?

@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #11139 (81d2302) into master (3735f11) will increase coverage by 0.00%.
The diff coverage is 60.00%.

@@           Coverage Diff            @@
##           master   #11139    +/-   ##
========================================
  Coverage   81.79%   81.79%            
========================================
  Files         162      162            
  Lines      188332   188443   +111     
  Branches    42834    42851    +17     
========================================
+ Hits       154040   154132    +92     
- Misses      21756    21760     +4     
- Partials    12536    12551    +15     
Flag Coverage Δ
huge-clang-none 82.68% <60.00%> (-0.01%) ⬇️
huge-gcc-none 53.72% <40.00%> (-0.85%) ⬇️
huge-gcc-testgui 52.15% <40.00%> (-0.85%) ⬇️
huge-gcc-unittests 0.29% <0.00%> (-0.01%) ⬇️
linux 82.44% <60.00%> (-0.03%) ⬇️
mingw-x64-HUGE 76.46% <40.00%> (-0.01%) ⬇️
mingw-x86-HUGE 77.31% <40.00%> (-0.03%) ⬇️
windows 78.12% <40.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
src/window.c 88.75% <60.00%> (-0.09%) ⬇️
src/vim9instr.c 81.46% <0.00%> (-1.03%) ⬇️
src/vim9cmds.c 85.70% <0.00%> (-0.53%) ⬇️
src/vim9execute.c 90.77% <0.00%> (-0.45%) ⬇️
src/message.c 78.69% <0.00%> (-0.23%) ⬇️
src/memline.c 80.20% <0.00%> (-0.21%) ⬇️
src/os_unix.c 66.82% <0.00%> (-0.17%) ⬇️
src/term.c 73.76% <0.00%> (-0.16%) ⬇️
src/charset.c 85.44% <0.00%> (-0.11%) ⬇️
src/terminal.c 77.61% <0.00%> (-0.09%) ⬇️
... and 16 more

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

src/window.c Outdated
// Make sure cursor is closer to topline than botline.
if (so == wp->w_height / 2
&& nlnum - wp->w_topline > wp->w_botline - 1 - nlnum)
wp->w_fraction += 1L;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will be covered by the test if we increase the loop range. Should we? Not sure how to determine what range will cover it. I tested it on my local system and confirmed this fixes a problem but when this happens depends on the window height the test runs in.

@brammool
Copy link
Contributor

brammool commented Sep 15, 2022 via email

@brammool
Copy link
Contributor

brammool commented Sep 15, 2022 via email

@luukvbaal
Copy link
Contributor Author

OK. Some combinations are not tested though, e.g. so=0 with ls=1.

Yes, it is rather arbitrary. Increasing the loop range will increase the coverage. Since the runtime is significantly smaller now, I guess we could afford to. But it's more about testing different values. I don't think each combination of options leads to different control flow in the code. If that were the case, we would need the nested loops.

Did you manage the reproduce the window resizing? I suppose it would
still happen with a reduced number of loops. Might as well do that.

I didn't try any further but no I couldn't reproduce it on my current system. I've seen it happening when I was testing gvim though. Feel free to add it, and/or increase the loop range when you include this patch, IDK if it matters.

We actually still have FEAT_FLOAT around float computations.
It probably isn't needed in most places, it actually means that we have
all the float functions, such as atan() and strod().

I think it's OK to use 0.5. If nothing breaks on any system then I'll
have a look into changing FEAT_FLOAT into the actually intended
HAVE_FLOAT_FUNCS. Or perhaps FEAT_EVAL_FLOAT. Or check each function
separately and only disable a tiny part that is using one.

TBH I added this because I was porting it to neovim and their CI was complaining about it. Do as you see fit.

Problem:    'splitscroll' test takes too long. Cursor position is not always maintained when not in normal mode.
Solution:   Get rid of nested for loops. Center cursor in window when not in insert mode.
@brammool
Copy link
Contributor

brammool commented Sep 16, 2022 via email

'splitbelow' 'sb' new window from split is below the current one
'splitright' 'spr' new window is put right of the current one
'splitscroll' 'spsc' determines scroll behavior when splitting windows
'splitscroll' 'spsc' determines scroll behavior for split windows
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was missed in 594f9e0.

@brammool
Copy link
Contributor

brammool commented Sep 16, 2022 via email

zeertzjq added a commit to luukvbaal/neovim that referenced this pull request Oct 6, 2022
vim-patch:9.0.0445: when opening/closing window text moves up/down

Problem:    When opening/closing window text moves up/down.
Solution:   Add the 'splitscroll' option.  When off text will keep its
            position as much as possible.
vim/vim@29ab524

vim-patch:9.0.0455: a few problems with 'splitscroll'

Problem:    A few problems with 'splitscroll'.
Solution:   Fix 'splitscroll' problems. (Luuk van Baal, closes vim/vim#11117)
vim/vim@5ed3917

vim-patch:9.0.0461: 'scroll' is not always updated

Problem:    'scroll' is not always updated.
Solution:   Call win_init_size() at the right place.
vim/vim@470a141

vim-patch:9.0.0465: cursor moves when cmdwin is closed when 'splitscroll' is off

Problem:    Cursor moves when cmdwin is closed when 'splitscroll' is off.
Solution:   Temporarily set 'splitscroll' when jumping back to the original
            window. (closes vim/vim#11128)
vim/vim@e697d48

vim-patch:9.0.0469: cursor moves if cmdwin is closed when 'splitscroll' is off

Problem:    Cursor moves if cmdwin is closed when 'splitscroll' is off.
Solution:   Skip win_fix_cursor if called when cmdwin is open or closing.
            (Luuk van Baal, closes vim/vim#11134)
vim/vim@3735f11

vim-patch:9.0.0478: test for 'splitscroll' takes too much time

Problem:    Test for 'splitscroll' takes too much time.
Solution:   Only test some of the combinations. (Luuk van Baal, closes vim/vim#11139)
vim/vim@594f9e0

vim-patch:9.0.0486: text scrolled with 'nosplitscroll', autocmd win and help

Problem:    Text scrolled with 'nosplitscroll', autocmd win opened and help
            window closed.
Solution:   Skip win_fix_scroll() in more situations. (Luuk van Baal,
            closes vim/vim#11150)
vim/vim@d5bc762

vim-patch:9.0.0505: various problems with 'nosplitscroll'

Problem:    Various problems with 'nosplitscroll'.
Solution:   Fix 'nosplitscroll' problems. (Luuk van Baal, closes vim/vim#11166)
vim/vim@faf1d41

vim-patch:9.0.0555: scrolling with 'nosplitscroll' in callback changing curwin

Problem:    Scrolling with 'nosplitscroll' in callback changing curwin.
Solution:   Invalidate w_cline_row in the right place. (Luuk van Baal,
            closes vim/vim#11185)
vim/vim@20e5856

vim-patch:9.0.0603: with 'nosplitscroll' folds are not handled correctly

Problem:    With 'nosplitscroll' folds are not handled correctly.
Solution:   Take care of closed folds when moving the cursor. (Luuk van Baal,
            closes vim/vim#11234)
vim/vim@7c1cbb6

vim-patch:9.0.0605: dump file missing

Problem:    Dump file missing.
Solution:   Add the missing dump file. (issue vim/vim#11234)
vim/vim@439a2ba

vim-patch:9.0.0647: the 'splitscroll' option is not a good name

Problem:    The 'splitscroll' option is not a good name.
Solution:   Rename 'splitscroll' to 'splitkeep' and make it a string option,
            also supporting "topline". (Luuk van Baal, closes vim/vim#11258)
vim/vim@13ece2a

vim-patch:9.0.0667: ml_get error when 'splitkeep' is "screen"

Problem:    ml_get error when 'splitkeep' is "screen". (Marius Gedminas)
Solution:   Check the botline is not too large. (Luuk van Baal,
            closes vim/vim#11293, closes vim/vim#11292)
vim/vim@346823d
zeertzjq pushed a commit to neovim/neovim that referenced this pull request Oct 6, 2022
vim-patch:9.0.0445: when opening/closing window text moves up/down

Problem:    When opening/closing window text moves up/down.
Solution:   Add the 'splitscroll' option.  When off text will keep its
            position as much as possible.
vim/vim@29ab524

vim-patch:9.0.0455: a few problems with 'splitscroll'

Problem:    A few problems with 'splitscroll'.
Solution:   Fix 'splitscroll' problems. (Luuk van Baal, closes vim/vim#11117)
vim/vim@5ed3917

vim-patch:9.0.0461: 'scroll' is not always updated

Problem:    'scroll' is not always updated.
Solution:   Call win_init_size() at the right place.
vim/vim@470a141

vim-patch:9.0.0465: cursor moves when cmdwin is closed when 'splitscroll' is off

Problem:    Cursor moves when cmdwin is closed when 'splitscroll' is off.
Solution:   Temporarily set 'splitscroll' when jumping back to the original
            window. (closes vim/vim#11128)
vim/vim@e697d48

vim-patch:9.0.0469: cursor moves if cmdwin is closed when 'splitscroll' is off

Problem:    Cursor moves if cmdwin is closed when 'splitscroll' is off.
Solution:   Skip win_fix_cursor if called when cmdwin is open or closing.
            (Luuk van Baal, closes vim/vim#11134)
vim/vim@3735f11

vim-patch:9.0.0478: test for 'splitscroll' takes too much time

Problem:    Test for 'splitscroll' takes too much time.
Solution:   Only test some of the combinations. (Luuk van Baal, closes vim/vim#11139)
vim/vim@594f9e0

vim-patch:9.0.0486: text scrolled with 'nosplitscroll', autocmd win and help

Problem:    Text scrolled with 'nosplitscroll', autocmd win opened and help
            window closed.
Solution:   Skip win_fix_scroll() in more situations. (Luuk van Baal,
            closes vim/vim#11150)
vim/vim@d5bc762

vim-patch:9.0.0505: various problems with 'nosplitscroll'

Problem:    Various problems with 'nosplitscroll'.
Solution:   Fix 'nosplitscroll' problems. (Luuk van Baal, closes vim/vim#11166)
vim/vim@faf1d41

vim-patch:9.0.0555: scrolling with 'nosplitscroll' in callback changing curwin

Problem:    Scrolling with 'nosplitscroll' in callback changing curwin.
Solution:   Invalidate w_cline_row in the right place. (Luuk van Baal,
            closes vim/vim#11185)
vim/vim@20e5856

vim-patch:9.0.0603: with 'nosplitscroll' folds are not handled correctly

Problem:    With 'nosplitscroll' folds are not handled correctly.
Solution:   Take care of closed folds when moving the cursor. (Luuk van Baal,
            closes vim/vim#11234)
vim/vim@7c1cbb6

vim-patch:9.0.0605: dump file missing

Problem:    Dump file missing.
Solution:   Add the missing dump file. (issue vim/vim#11234)
vim/vim@439a2ba

vim-patch:9.0.0647: the 'splitscroll' option is not a good name

Problem:    The 'splitscroll' option is not a good name.
Solution:   Rename 'splitscroll' to 'splitkeep' and make it a string option,
            also supporting "topline". (Luuk van Baal, closes vim/vim#11258)
vim/vim@13ece2a

vim-patch:9.0.0667: ml_get error when 'splitkeep' is "screen"

Problem:    ml_get error when 'splitkeep' is "screen". (Marius Gedminas)
Solution:   Check the botline is not too large. (Luuk van Baal,
            closes vim/vim#11293, closes vim/vim#11292)
vim/vim@346823d
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.

3 participants