diff src/testdir/test_window_cmd.vim @ 30624:f2f35161d75a v9.0.0647

patch 9.0.0647: the 'splitscroll' option is not a good name Commit: https://github.com/vim/vim/commit/13ece2ae1d09009d3fb8acf858c288e7848ecdac Author: Luuk van Baal <luukvbaal@gmail.com> Date: Mon Oct 3 15:28:08 2022 +0100 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 #11258)
author Bram Moolenaar <Bram@vim.org>
date Mon, 03 Oct 2022 16:30:04 +0200
parents 04df44c52d65
children ac908e454519
line wrap: on
line diff
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -1632,31 +1632,29 @@ func Test_win_equal_last_status()
   set laststatus&
 endfunc
 
-" Ensure no scrolling happens with 'nosplitscroll' for a sequence of
+" Test "screen" and "cursor" values for 'splitkeep' with a sequence of
 " split operations for various options: with and without a winbar,
 " tabline, for each possible value of 'laststatus', 'scrolloff',
-" 'equalalways', and regardless of the cursor position.
-func Test_nosplitscroll_options()
-  set nowrap
-  set nosplitscroll
-
+" 'equalalways', and with the cursor at the top, middle and bottom.
+func Test_splitkeep_options()
   " 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 % 4) ? 0 : run)
-    execute 'set laststatus=' . (run % 3)
-    execute 'set ' . ((run % 2) ? 'equalalways' : 'noequalalways')
-    execute 'set ' . ((run % 3) ? 'splitbelow' : 'nosplitbelow')
+  for run in range(0, 20)
+    let &splitkeep = run > 10 ? 'topline' : 'screen'
+    let &scrolloff = (!(run % 4) ? 0 : run)
+    let &laststatus = (run % 3)
+    let &splitbelow = (run % 3)
+    let &equalalways = (run % 2)
+    let wsb = (run % 2) && &splitbelow
+    let tl = (gui ? 0 : ((run % 5) ? 1 : 0))
+    let pos = !(run % 3) ? 'H' : ((run % 2) ? 'M' : 'L')
+    tabnew | tabonly! | redraw
     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
@@ -1672,17 +1670,17 @@ func Test_nosplitscroll_options()
     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"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, line("w0"))
 
     " No scroll when resizing windows
-    wincmd k | resize +2
+    wincmd k | resize +2 | redraw
     call assert_equal(1, line("w0"))
     wincmd j
-    call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, 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"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, line("w0"))
     wincmd k
     call assert_equal(1, line("w0"))
 
@@ -1690,9 +1688,9 @@ func Test_nosplitscroll_options()
     set lines+=2
     call assert_equal(1, line("w0"))
     wincmd j
-    call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, line("w0"))
     set lines-=2
-    call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, line("w0"))
     wincmd k
     call assert_equal(1, line("w0"))
 
@@ -1700,23 +1698,23 @@ func Test_nosplitscroll_options()
     wincmd =
     call assert_equal(1, line("w0"))
     wincmd j
-    call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, 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"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, line("w0"))
     1wincmd w | quit | wincmd l | split
-    call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, line("w0"))
     wincmd j
-    call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, 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"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, line("w0"))
 
     " No scroll for vertical split
     quit | vsplit | wincmd l
@@ -1725,8 +1723,8 @@ func Test_nosplitscroll_options()
     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"))
+    quit | redraw | split | split | quit | redraw
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl - wsb, line("w0"))
 
     " No scroll for new buffer
     1wincmd w | only | copen | wincmd k
@@ -1734,7 +1732,7 @@ func Test_nosplitscroll_options()
     only
     call assert_equal(1, line("w0"))
     above copen | wincmd j
-    call assert_equal(win_screenpos(0)[0] - tabline, line("w0"))
+    call assert_equal(&spk == 'topline' ? 1 : win_screenpos(0)[0] - tl, line("w0"))
 
     " No scroll when opening cmdwin, and no cursor move when closing cmdwin.
     only | norm ggL
@@ -1751,22 +1749,21 @@ func Test_nosplitscroll_options()
     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"))
+    call assert_equal(&spk == 'topline' ? 6 : 5 + win_screenpos(0)[0] - tl - wsb, line("w0"))
   endfor
 
   tabnew | tabonly! | %bwipeout!
   iunmap c
-  set wrap&
   set scrolloff&
   set splitbelow&
   set laststatus&
   set equalalways&
-  set splitscroll&
+  set splitkeep&
   let &t_WS = save_WS
 endfunc
 
-function Test_nosplitscroll_cmdwin_cursor_position()
-  set nosplitscroll
+function Test_splitkeep_cmdwin_cursor_position()
+  set splitkeep=screen
   call setline(1, range(&lines))
 
   " No scroll when cursor is at near bottom of window and cusor position
@@ -1789,11 +1786,11 @@ function Test_nosplitscroll_cmdwin_curso
   call assert_equal(1, col('.'))
 
   %bwipeout!
-  set splitscroll&
+  set splitkeep&
 endfunction
 
-function Test_nosplitscroll_misc()
-  set nosplitscroll
+function Test_splitkeep_misc()
+  set splitkeep=screen
   set splitbelow
 
   call setline(1, range(1, &lines))
@@ -1815,67 +1812,68 @@ function Test_nosplitscroll_misc()
 
   %bwipeout!
   set splitbelow&
-  set splitscroll&
+  set splitkeep&
 endfunc
 
-function Test_nosplitscroll_callback()
+function Test_splitkeep_callback()
   CheckScreendump
   let lines =<< trim END
-    set nosplitscroll
+    set splitkeep=screen
     call setline(1, range(&lines))
-    function WincmdCb(a, b)
+    function C1(a, b)
       split | wincmd p
     endfunction
-    function TermCb(a, b)
+    function C2(a, b)
       close | split
     endfunction
-    nnoremap t <cmd>call popup_create(term_start(&shell, { 'hidden': 1, 'exit_cb': 'TermCb' }), {})<CR>
-    nnoremap j <cmd>call job_start([&shell, &shellcmdflag, "echo"], { 'exit_cb': 'WincmdCb' })<CR>
+    nn j <cmd>call job_start([&sh, &shcf, "true"], { 'exit_cb': 'C1' })<CR>
+    nn t <cmd>call popup_create(term_start([&sh, &shcf, "true"],
+          \ { 'hidden': 1, 'exit_cb': 'C2' }), {})<CR>
   END
-  call writefile(lines, 'XTestNosplitscrollCallback', 'D')
-  let buf = RunVimInTerminal('-S XTestNosplitscrollCallback', #{rows: 8})
+  call writefile(lines, 'XTestSplitkeepCallback', 'D')
+  let buf = RunVimInTerminal('-S XTestSplitkeepCallback', #{rows: 8})
 
   call term_sendkeys(buf, "j")
-  call VerifyScreenDump(buf, 'Test_nosplitscroll_callback_1', {})
+  call VerifyScreenDump(buf, 'Test_splitkeep_callback_1', {})
 
-  call term_sendkeys(buf, ":quit\<CR>Htexit\<CR>")
-  call VerifyScreenDump(buf, 'Test_nosplitscroll_callback_2', {})
+  call term_sendkeys(buf, ":quit\<CR>Ht")
+  call VerifyScreenDump(buf, 'Test_splitkeep_callback_2', {})
 
   call term_sendkeys(buf, ":set sb\<CR>:quit\<CR>Gj")
-  call VerifyScreenDump(buf, 'Test_nosplitscroll_callback_3', {})
+  call VerifyScreenDump(buf, 'Test_splitkeep_callback_3', {})
 
-  call term_sendkeys(buf, ":quit\<CR>Gtexit\<CR>")
-  call VerifyScreenDump(buf, 'Test_nosplitscroll_callback_4', {})
+  call term_sendkeys(buf, ":quit\<CR>Gt")
+  call VerifyScreenDump(buf, 'Test_splitkeep_callback_4', {})
 endfunc
 
-function Test_nosplitscroll_fold()
-CheckScreendump
+function Test_splitkeep_fold()
+  CheckScreendump
 
-let lines =<< trim END
-  set nosplitscroll
-  set foldmethod=marker
-  set number
-  let line = 1
-  for n in range(1, &lines)
-    call setline(line, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
-          \ 'after fold'])
-    let line += 8
-  endfor
-END
-  call writefile(lines, 'XTestNosplitscrollFold', 'D')
-  let buf = RunVimInTerminal('-S XTestNosplitscrollFold', #{rows: 10})
+  let lines =<< trim END
+    set splitkeep=screen
+    set foldmethod=marker
+    set number
+    let line = 1
+    for n in range(1, &lines)
+      call setline(line, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
+            \ 'after fold'])
+      let line += 8
+    endfor
+  END
+  call writefile(lines, 'XTestSplitkeepFold', 'D')
+  let buf = RunVimInTerminal('-S XTestSplitkeepFold', #{rows: 10})
 
   call term_sendkeys(buf, "L:wincmd s\<CR>")
-  call VerifyScreenDump(buf, 'Test_nosplitscroll_fold_1', {})
+  call VerifyScreenDump(buf, 'Test_splitkeep_fold_1', {})
 
   call term_sendkeys(buf, ":quit\<CR>")
-  call VerifyScreenDump(buf, 'Test_nosplitscroll_fold_2', {})
+  call VerifyScreenDump(buf, 'Test_splitkeep_fold_2', {})
 
   call term_sendkeys(buf, "H:below split\<CR>")
-  call VerifyScreenDump(buf, 'Test_nosplitscroll_fold_3', {})
+  call VerifyScreenDump(buf, 'Test_splitkeep_fold_3', {})
 
   call term_sendkeys(buf, ":wincmd k\<CR>:quit\<CR>")
-  call VerifyScreenDump(buf, 'Test_nosplitscroll_fold_4', {})
+  call VerifyScreenDump(buf, 'Test_splitkeep_fold_4', {})
 endfunction
 
 " vim: shiftwidth=2 sts=2 expandtab