Patch 9.0.0478
Problem:    Test for 'splitscroll' takes too much time.
Solution:   Only test some of the combinations. (Luuk van Baal, closes #11139)
Files:      runtime/optwin.vim, src/window.c src/testdir/test_window_cmd.vim


*** ../vim-9.0.0477/runtime/optwin.vim  2022-09-11 16:59:48.934110049 +0100
--- runtime/optwin.vim  2022-09-16 12:44:38.247336905 +0100
***************
*** 515,521 ****
  call <SID>BinOptionG("sb", &sb)
  call <SID>AddOption("splitright", gettext("a new window is put right of the 
current one"))
  call <SID>BinOptionG("spr", &spr)
! call <SID>AddOption("splitscroll", gettext("determines scroll behavior when 
spliting windows"))
  call <SID>BinOptionG("spsc", &spsc)
  call <SID>AddOption("scrollbind", gettext("this window scrolls together with 
other bound windows"))
  call append("$", "\t" .. s:local_to_window)
--- 515,521 ----
  call <SID>BinOptionG("sb", &sb)
  call <SID>AddOption("splitright", gettext("a new window is put right of the 
current one"))
  call <SID>BinOptionG("spr", &spr)
! call <SID>AddOption("splitscroll", gettext("determines scroll behavior for 
split windows"))
  call <SID>BinOptionG("spsc", &spsc)
  call <SID>AddOption("scrollbind", gettext("this window scrolls together with 
other bound windows"))
  call append("$", "\t" .. s:local_to_window)
*** ../vim-9.0.0477/src/window.c        2022-09-15 12:43:20.476321981 +0100
--- src/window.c        2022-09-16 12:44:38.247336905 +0100
***************
*** 6403,6409 ****
      static void
  win_fix_cursor(int normal)
  {
-     int      top = FALSE;
      win_T    *wp = curwin;
      long     so = get_scrolloff_value();
      linenr_T nlnum = 0;
--- 6403,6408 ----
***************
*** 6418,6424 ****
      so = MIN(wp->w_height / 2, so);
      // Check if cursor position is above topline or below botline.
      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);
      else if (wp->w_cursor.lnum > (wp->w_botline - so - 1)
            && (wp->w_botline - wp->w_buffer->b_ml.ml_line_count) != 1)
        nlnum = MAX(wp->w_botline - so - 1, 1);
--- 6417,6423 ----
      so = MIN(wp->w_height / 2, so);
      // Check if cursor position is above topline or below botline.
      if (wp->w_cursor.lnum < (wp->w_topline + so) && wp->w_topline != 1)
!       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)
            && (wp->w_botline - wp->w_buffer->b_ml.ml_line_count) != 1)
        nlnum = MAX(wp->w_botline - so - 1, 1);
***************
*** 6436,6442 ****
        }
        else
        {   // Ensure cursor stays visible if we are not in normal mode.
!           wp->w_fraction = top ? 0 : FRACTION_MULT;
            scroll_to_fraction(wp, wp->w_prev_height);
        }
      }
--- 6435,6445 ----
        }
        else
        {   // Ensure cursor stays visible if we are not in normal mode.
!           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);
        }
      }
*** ../vim-9.0.0477/src/testdir/test_window_cmd.vim     2022-09-15 
17:44:03.726468280 +0100
--- src/testdir/test_window_cmd.vim     2022-09-16 12:48:37.514670322 +0100
***************
*** 1637,1763 ****
  func Test_splitscroll_with_splits()
    set nowrap
    set nosplitscroll
    let gui = has("gui_running")
!   inoremap c <cmd>:copen<CR>
!   for winbar in [0, 1]
!     for sb in [0, 1]
!       for ea in [0, 1]
!         for tab in [0, 1]
!           for so in [0, 5]
!             for ls in range(0, 2)
!               for pos in ["H", "M", "L"]
!               tabnew | tabonly! | redraw
!               let tabline = (gui ? 0 : (tab ? 1 : 0))
!               let winbar_sb = (sb ? winbar : 0)
!               execute 'set scrolloff=' . so
!               execute 'set laststatus=' . ls
!               execute 'set ' . (ea ? 'equalalways' : 'noequalalways')
!               execute 'set ' . (sb ? 'splitbelow' : 'nosplitbelow')
!               execute tab ? 'tabnew' : ''
!               execute winbar ? 'nnoremenu 1.10 WinBar.Test :echo' : ''
!               call setline(1, range(1, 256))
!               " No scroll for restore_snapshot
!               norm G
!               try
!                 copen | close | colder
!               catch /E380/
!               endtry
!               call assert_equal(257 - winheight(0), line("w0"))
! 
!               " No scroll for firstwin horizontal split
!               execute 'norm gg' . pos
!               split | redraw | wincmd k
!               call assert_equal(1, line("w0"))
!               call assert_equal(&scroll, winheight(0) / 2)
!               wincmd j
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
! 
!               " No scroll when resizing windows
!               wincmd k | resize +2
!               call assert_equal(1, line("w0"))
!               wincmd j
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
! 
!               " No scroll when dragging statusline
!               call win_move_statusline(1, -3)
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
!               wincmd k
!               call assert_equal(1, line("w0"))
! 
!               " No scroll when changing shellsize
!               set lines+=2
!               call assert_equal(1, line("w0"))
!               wincmd j
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
!               set lines-=2
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
!               wincmd k
!               call assert_equal(1, line("w0"))
! 
!               " No scroll when equalizing windows
!               wincmd =
!               call assert_equal(1, line("w0"))
!               wincmd j
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
!               wincmd k
!               call assert_equal(1, line("w0"))
! 
!               " No scroll in windows split multiple times
!               vsplit | split | 4wincmd w
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
!               1wincmd w | quit | wincmd l | split
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
!               wincmd j
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
! 
!               " No scroll in small window
!               2wincmd w | only | 5split | wincmd k
!               call assert_equal(1, line("w0"))
!               wincmd j
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
! 
!               " No scroll for vertical split
!               quit | vsplit | wincmd l
!               call assert_equal(1, line("w0"))
!               wincmd h
!               call assert_equal(1, line("w0"))
! 
!               " No scroll in windows split and quit multiple times
!               quit | redraw | split | redraw | split | redraw | quit | redraw
!               call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
! 
!               " No scroll for new buffer
!               1wincmd w | only | copen | wincmd k
!               call assert_equal(1, line("w0"))
!               only
!               call assert_equal(1, line("w0"))
!               above copen | wincmd j
!               call assert_equal(win_screenpos(0)[0] - tabline, line("w0"))
! 
!               " No scroll when opening cmdwin, and no cursor move when closing
!               " cmdwin.
!               only | norm ggL
!               let curpos = getcurpos()
!               norm q:
!               call assert_equal(1, line("w0"))
!               call assert_equal(curpos, getcurpos())
! 
!               " Scroll when cursor becomes invalid in insert mode
!               norm Lic
!               wincmd k | only
!               call assert_notequal(1, line("w0"))
! 
!               " No scroll when topline not equal to 1
!               execute "norm gg5\<C-e>" | split | wincmd k
!               call assert_equal(6, line("w0"))
!               wincmd j
!               call assert_equal(5 + win_screenpos(0)[0] - tabline - 
winbar_sb, line("w0"))
!               endfor
!             endfor
!           endfor
!         endfor
!       endfor
!     endfor
    endfor
  
    tabnew | tabonly! | %bwipeout!
--- 1637,1755 ----
  func Test_splitscroll_with_splits()
    set nowrap
    set nosplitscroll
+ 
+   " disallow window resizing
+   let save_WS = &t_WS
+   set t_WS=
+ 
    let gui = has("gui_running")
!   inoremap <expr> c "<cmd>copen<bar>wincmd k<CR>"
!   for run in range(0, 10)
!     tabnew | tabonly! | redraw    
!     let tabline = (gui ? 0 : ((run % 5) ? 1 : 0))
!     let winbar_sb = (run % 2) && (run % 3)
!     execute 'set scrolloff=' . !(run % 3) ? 0 : run
!     execute 'set laststatus=' . (run % 3)
!     execute 'set ' . ((run % 2) ? 'equalalways' : 'noequalalways')
!     execute 'set ' . ((run % 3) ? 'splitbelow' : 'nosplitbelow')
!     execute (run % 5) ? 'tabnew' : ''
!     execute (run % 2) ? 'nnoremenu 1.10 WinBar.Test :echo' : ''
!     let pos = !(run % 3) ? 'H' : ((run % 2) ? 'M' : 'L')
!     call setline(1, range(1, 256))
!     " No scroll for restore_snapshot
!     norm G
!     try
!       copen | close | colder
!     catch /E380/
!     endtry
!     call assert_equal(257 - winheight(0), line("w0"))
! 
!     " No scroll for firstwin horizontal split
!     execute 'norm gg' . pos
!     split | redraw | wincmd k
!     call assert_equal(1, line("w0"))
!     call assert_equal(&scroll, winheight(0) / 2)
!     wincmd j
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
! 
!     " No scroll when resizing windows
!     wincmd k | resize +2
!     call assert_equal(1, line("w0"))
!     wincmd j
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
! 
!     " No scroll when dragging statusline
!     call win_move_statusline(1, -3)
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
!     wincmd k
!     call assert_equal(1, line("w0"))
! 
!     " No scroll when changing shellsize
!     set lines+=2
!     call assert_equal(1, line("w0"))
!     wincmd j
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
!     set lines-=2
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
!     wincmd k
!     call assert_equal(1, line("w0"))
! 
!     " No scroll when equalizing windows
!     wincmd =
!     call assert_equal(1, line("w0"))
!     wincmd j
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
!     wincmd k
!     call assert_equal(1, line("w0"))
! 
!     " No scroll in windows split multiple times
!     vsplit | split | 4wincmd w
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
!     1wincmd w | quit | wincmd l | split
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
!     wincmd j
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
! 
!     " No scroll in small window
!     2wincmd w | only | 5split | wincmd k
!     call assert_equal(1, line("w0"))
!     wincmd j
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
! 
!     " No scroll for vertical split
!     quit | vsplit | wincmd l
!     call assert_equal(1, line("w0"))
!     wincmd h
!     call assert_equal(1, line("w0"))
! 
!     " No scroll in windows split and quit multiple times
!     quit | redraw | split | redraw | split | redraw | quit | redraw
!     call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
! 
!     " No scroll for new buffer
!     1wincmd w | only | copen | wincmd k
!     call assert_equal(1, line("w0"))
!     only
!     call assert_equal(1, line("w0"))
!     above copen | wincmd j
!     call assert_equal(win_screenpos(0)[0] - tabline, line("w0"))
! 
!     " No scroll when opening cmdwin, and no cursor move when closing cmdwin.
!     only | norm ggL
!     let curpos = getcurpos()
!     norm q:
!     call assert_equal(1, line("w0"))
!     call assert_equal(curpos, getcurpos())
! 
!     " Scroll when cursor becomes invalid in insert mode
!     norm Lic
!     call assert_equal(curpos, getcurpos())
! 
!     " No scroll when topline not equal to 1
!     only | execute "norm gg5\<C-e>" | split | wincmd k
!     call assert_equal(6, line("w0"))
!     wincmd j
!     call assert_equal(5 + win_screenpos(0)[0] - tabline - winbar_sb, 
line("w0"))
    endfor
  
    tabnew | tabonly! | %bwipeout!
***************
*** 1768,1773 ****
--- 1760,1766 ----
    set laststatus&
    set equalalways&
    set splitscroll&
+   let &t_WS = save_WS
  endfunc
  
  function Test_nosplitscroll_cmdwin_cursor_position()
*** ../vim-9.0.0477/src/version.c       2022-09-16 12:28:29.342066929 +0100
--- src/version.c       2022-09-16 12:46:10.323080242 +0100
***************
*** 705,706 ****
--- 705,708 ----
  {   /* Add new patch number below this line */
+ /**/
+     478,
  /**/

-- 
>From "know your smileys":
 O:-)   Saint

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220916115329.377CC1C0852%40moolenaar.net.

Raspunde prin e-mail lui