@@ -1631,5 +1631,133 @@ func Test_win_equal_last_status()
16311631 set laststatus &
16321632endfunc
16331633
1634+ " Ensure no scrolling happens with 'nosplitscroll' with and without a
1635+ " winbar, tabline, for each possible value of 'laststatus', 'scrolloff',
1636+ " 'equalalways', and regardless of the cursor position.
1637+ func Test_splitscroll_with_splits ()
1638+ set nowrap
1639+ set nosplitscroll
1640+ let gui = has (" gui_running" )
1641+ inoremap c <cmd> :copen<CR>
1642+ for winbar in [0 , 1 ]
1643+ for sb in [0 , 1 ]
1644+ for ea in [0 , 1 ]
1645+ for tab in [0 , 1 ]
1646+ for so in [0 , 5 ]
1647+ for ls in range (0 , 2 )
1648+ for pos in [" H" , " M" , " L" ]
1649+ let tabline = (gui ? 0 : (tab ? 1 : 0 ))
1650+ let winbar_sb = (sb ? winbar : 0 )
1651+ execute ' set scrolloff=' . so
1652+ execute ' set laststatus=' . ls
1653+ execute ' set ' . (ea ? ' equalalways' : ' noequalalways' )
1654+ execute ' set ' . (sb ? ' splitbelow' : ' nosplitbelow' )
1655+ execute tab ? ' tabnew' : ' '
1656+ execute winbar ? ' nnoremenu 1.10 WinBar.Test :echo' : ' '
1657+ call setline (1 , range (1 , 256 ))
1658+ execute ' norm gg' . pos
1659+ " No scroll for vertical split and quit
1660+ vsplit | quit
1661+ call assert_equal (1 , line (" w0" ))
1662+
1663+ " No scroll for horizontal split
1664+ split | redraw ! | wincmd k
1665+ call assert_equal (1 , line (" w0" ))
1666+
1667+ " No scroll when resizing windows
1668+ resize + 2
1669+ call assert_equal (1 , line (" w0" ))
1670+ wincmd j
1671+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1672+
1673+ " No scroll when dragging statusline
1674+ call win_move_statusline (1 , -3 )
1675+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1676+ wincmd k
1677+ call assert_equal (1 , line (" w0" ))
1678+
1679+ " No scroll when changing shellsize
1680+ set lines += 2
1681+ call assert_equal (1 , line (" w0" ))
1682+ wincmd j
1683+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1684+ set lines -= 2
1685+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1686+ wincmd k
1687+ call assert_equal (1 , line (" w0" ))
1688+
1689+ " No scroll when equalizing windows
1690+ wincmd =
1691+ call assert_equal (1 , line (" w0" ))
1692+ wincmd j
1693+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1694+ wincmd k
1695+ call assert_equal (1 , line (" w0" ))
1696+
1697+ " No scroll in windows split multiple times
1698+ vsplit | split | 4 wincmd w
1699+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1700+ 1 wincmd w | quit | wincmd l | split
1701+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1702+ wincmd j
1703+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1704+
1705+ " No scroll in small window
1706+ 2 wincmd w | only | 5 split | wincmd k
1707+ call assert_equal (1 , line (" w0" ))
1708+ wincmd j
1709+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1710+
1711+ " No scroll for vertical split
1712+ quit | vsplit | wincmd l
1713+ call assert_equal (1 , line (" w0" ))
1714+ wincmd h
1715+ call assert_equal (1 , line (" w0" ))
1716+
1717+ " No scroll in windows split and quit multiple times
1718+ quit | split | split | quit
1719+ call assert_equal (win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1720+
1721+ " No scroll for new buffer
1722+ 1 wincmd w | only | copen | wincmd k
1723+ call assert_equal (1 , line (" w0" ))
1724+ only
1725+ call assert_equal (1 , line (" w0" ))
1726+ above copen | wincmd j
1727+ call assert_equal (win_screenpos (0 )[0 ] - tabline , line (" w0" ))
1728+
1729+ " No scroll when opening cmdwin
1730+ only | norm ggLq:
1731+ call assert_equal (1 , line (" w0" ))
1732+
1733+ " Scroll when cursor becomes invalid in insert mode
1734+ norm Lic
1735+ wincmd k | only
1736+ call assert_notequal (1 , line (" w0" ))
1737+
1738+ " No scroll when topline not equal to 1
1739+ execute " norm gg5\<C-e> " | split | wincmd k
1740+ call assert_equal (6 , line (" w0" ))
1741+ wincmd j
1742+ call assert_equal (5 + win_screenpos (0 )[0 ] - tabline - winbar_sb, line (" w0" ))
1743+ only
1744+ endfor
1745+ endfor
1746+ endfor
1747+ tabonly !
1748+ endfor
1749+ endfor
1750+ endfor
1751+ endfor
1752+
1753+ tabnew | tabonly ! | % bwipeout !
1754+ iunmap c
1755+ set wrap &
1756+ set scrolloff &
1757+ set splitbelow &
1758+ set laststatus &
1759+ set equalalways &
1760+ set splitscroll&
1761+ endfunc
16341762
16351763" vim: shiftwidth = 2 sts = 2 expandtab
0 commit comments