0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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 #11139)
This commit is contained in:
Luuk van Baal 2022-09-16 12:52:58 +01:00 committed by Bram Moolenaar
parent 3e8b7a6056
commit 594f9e09cd
4 changed files with 109 additions and 111 deletions

View File

@ -515,7 +515,7 @@ call <SID>AddOption("splitbelow", gettext("a new window is put below the current
call <SID>BinOptionG("sb", &sb) call <SID>BinOptionG("sb", &sb)
call <SID>AddOption("splitright", gettext("a new window is put right of the current one")) call <SID>AddOption("splitright", gettext("a new window is put right of the current one"))
call <SID>BinOptionG("spr", &spr) call <SID>BinOptionG("spr", &spr)
call <SID>AddOption("splitscroll", gettext("determines scroll behavior when spliting windows")) call <SID>AddOption("splitscroll", gettext("determines scroll behavior for split windows"))
call <SID>BinOptionG("spsc", &spsc) call <SID>BinOptionG("spsc", &spsc)
call <SID>AddOption("scrollbind", gettext("this window scrolls together with other bound windows")) call <SID>AddOption("scrollbind", gettext("this window scrolls together with other bound windows"))
call append("$", "\t" .. s:local_to_window) call append("$", "\t" .. s:local_to_window)

View File

@ -1637,127 +1637,119 @@ endfunc
func Test_splitscroll_with_splits() func Test_splitscroll_with_splits()
set nowrap set nowrap
set nosplitscroll set nosplitscroll
" disallow window resizing
let save_WS = &t_WS
set t_WS=
let gui = has("gui_running") let gui = has("gui_running")
inoremap c <cmd>:copen<CR> inoremap <expr> c "<cmd>copen<bar>wincmd k<CR>"
for winbar in [0, 1] for run in range(0, 10)
for sb in [0, 1] tabnew | tabonly! | redraw
for ea in [0, 1] let tabline = (gui ? 0 : ((run % 5) ? 1 : 0))
for tab in [0, 1] let winbar_sb = (run % 2) && (run % 3)
for so in [0, 5] execute 'set scrolloff=' . !(run % 3) ? 0 : run
for ls in range(0, 2) execute 'set laststatus=' . (run % 3)
for pos in ["H", "M", "L"] execute 'set ' . ((run % 2) ? 'equalalways' : 'noequalalways')
tabnew | tabonly! | redraw execute 'set ' . ((run % 3) ? 'splitbelow' : 'nosplitbelow')
let tabline = (gui ? 0 : (tab ? 1 : 0)) execute (run % 5) ? 'tabnew' : ''
let winbar_sb = (sb ? winbar : 0) execute (run % 2) ? 'nnoremenu 1.10 WinBar.Test :echo' : ''
execute 'set scrolloff=' . so let pos = !(run % 3) ? 'H' : ((run % 2) ? 'M' : 'L')
execute 'set laststatus=' . ls call setline(1, range(1, 256))
execute 'set ' . (ea ? 'equalalways' : 'noequalalways') " No scroll for restore_snapshot
execute 'set ' . (sb ? 'splitbelow' : 'nosplitbelow') norm G
execute tab ? 'tabnew' : '' try
execute winbar ? 'nnoremenu 1.10 WinBar.Test :echo' : '' copen | close | colder
call setline(1, range(1, 256)) catch /E380/
" No scroll for restore_snapshot endtry
norm G call assert_equal(257 - winheight(0), line("w0"))
try
copen | close | colder
catch /E380/
endtry
call assert_equal(257 - winheight(0), line("w0"))
" No scroll for firstwin horizontal split " No scroll for firstwin horizontal split
execute 'norm gg' . pos execute 'norm gg' . pos
split | redraw | wincmd k split | redraw | wincmd k
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
call assert_equal(&scroll, winheight(0) / 2) call assert_equal(&scroll, winheight(0) / 2)
wincmd j wincmd j
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
" No scroll when resizing windows " No scroll when resizing windows
wincmd k | resize +2 wincmd k | resize +2
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
wincmd j wincmd j
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
" No scroll when dragging statusline " No scroll when dragging statusline
call win_move_statusline(1, -3) call win_move_statusline(1, -3)
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
wincmd k wincmd k
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
" No scroll when changing shellsize " No scroll when changing shellsize
set lines+=2 set lines+=2
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
wincmd j wincmd j
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
set lines-=2 set lines-=2
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
wincmd k wincmd k
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
" No scroll when equalizing windows " No scroll when equalizing windows
wincmd = wincmd =
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
wincmd j wincmd j
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
wincmd k wincmd k
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
" No scroll in windows split multiple times " No scroll in windows split multiple times
vsplit | split | 4wincmd w vsplit | split | 4wincmd w
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
1wincmd w | quit | wincmd l | split 1wincmd w | quit | wincmd l | split
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
wincmd j wincmd j
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
" No scroll in small window " No scroll in small window
2wincmd w | only | 5split | wincmd k 2wincmd w | only | 5split | wincmd k
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
wincmd j wincmd j
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
" No scroll for vertical split " No scroll for vertical split
quit | vsplit | wincmd l quit | vsplit | wincmd l
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
wincmd h wincmd h
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
" No scroll in windows split and quit multiple times " No scroll in windows split and quit multiple times
quit | redraw | split | redraw | split | redraw | quit | redraw quit | redraw | split | redraw | split | redraw | quit | redraw
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
" No scroll for new buffer " No scroll for new buffer
1wincmd w | only | copen | wincmd k 1wincmd w | only | copen | wincmd k
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
only only
call assert_equal(1, line("w0")) call assert_equal(1, line("w0"))
above copen | wincmd j above copen | wincmd j
call assert_equal(win_screenpos(0)[0] - tabline, line("w0")) call assert_equal(win_screenpos(0)[0] - tabline, line("w0"))
" No scroll when opening cmdwin, and no cursor move when closing " No scroll when opening cmdwin, and no cursor move when closing cmdwin.
" cmdwin. only | norm ggL
only | norm ggL let curpos = getcurpos()
let curpos = getcurpos() norm q:
norm q: call assert_equal(1, line("w0"))
call assert_equal(1, line("w0")) call assert_equal(curpos, getcurpos())
call assert_equal(curpos, getcurpos())
" Scroll when cursor becomes invalid in insert mode " Scroll when cursor becomes invalid in insert mode
norm Lic norm Lic
wincmd k | only call assert_equal(curpos, getcurpos())
call assert_notequal(1, line("w0"))
" No scroll when topline not equal to 1 " No scroll when topline not equal to 1
execute "norm gg5\<C-e>" | split | wincmd k only | execute "norm gg5\<C-e>" | split | wincmd k
call assert_equal(6, line("w0")) call assert_equal(6, line("w0"))
wincmd j wincmd j
call assert_equal(5 + win_screenpos(0)[0] - tabline - winbar_sb, line("w0")) call assert_equal(5 + win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
endfor
endfor
endfor
endfor
endfor
endfor
endfor endfor
tabnew | tabonly! | %bwipeout! tabnew | tabonly! | %bwipeout!
@ -1768,6 +1760,7 @@ func Test_splitscroll_with_splits()
set laststatus& set laststatus&
set equalalways& set equalalways&
set splitscroll& set splitscroll&
let &t_WS = save_WS
endfunc endfunc
function Test_nosplitscroll_cmdwin_cursor_position() function Test_nosplitscroll_cmdwin_cursor_position()

View File

@ -703,6 +703,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
478,
/**/ /**/
477, 477,
/**/ /**/

View File

@ -6403,7 +6403,6 @@ win_fix_scroll(int resize)
static void static void
win_fix_cursor(int normal) win_fix_cursor(int normal)
{ {
int top = FALSE;
win_T *wp = curwin; win_T *wp = curwin;
long so = get_scrolloff_value(); long so = get_scrolloff_value();
linenr_T nlnum = 0; linenr_T nlnum = 0;
@ -6418,7 +6417,7 @@ win_fix_cursor(int normal)
so = MIN(wp->w_height / 2, so); so = MIN(wp->w_height / 2, so);
// Check if cursor position is above topline or below botline. // Check if cursor position is above topline or below botline.
if (wp->w_cursor.lnum < (wp->w_topline + so) && wp->w_topline != 1) if (wp->w_cursor.lnum < (wp->w_topline + so) && wp->w_topline != 1)
top = nlnum = MIN(wp->w_topline + so, wp->w_buffer->b_ml.ml_line_count); nlnum = MIN(wp->w_topline + so, wp->w_buffer->b_ml.ml_line_count);
else if (wp->w_cursor.lnum > (wp->w_botline - so - 1) else if (wp->w_cursor.lnum > (wp->w_botline - so - 1)
&& (wp->w_botline - wp->w_buffer->b_ml.ml_line_count) != 1) && (wp->w_botline - wp->w_buffer->b_ml.ml_line_count) != 1)
nlnum = MAX(wp->w_botline - so - 1, 1); nlnum = MAX(wp->w_botline - so - 1, 1);
@ -6436,7 +6435,11 @@ win_fix_cursor(int normal)
} }
else else
{ // Ensure cursor stays visible if we are not in normal mode. { // Ensure cursor stays visible if we are not in normal mode.
wp->w_fraction = top ? 0 : FRACTION_MULT; wp->w_fraction = 0.5 * FRACTION_MULT;
// 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++;
scroll_to_fraction(wp, wp->w_prev_height); scroll_to_fraction(wp, wp->w_prev_height);
} }
} }