comparison src/testdir/test_window_cmd.vim @ 34389:8b0e390b61fe v9.1.0121

patch 9.1.0121: Infinite loop or signed overflow with 'smoothscroll' Commit: https://github.com/vim/vim/commit/02fcae02a926e4e8379d77fb716da4202029882d Author: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Wed Feb 21 19:40:44 2024 +0100 patch 9.1.0121: Infinite loop or signed overflow with 'smoothscroll' Problem: infinite loop in win_update with 'smoothscroll' set when window width is equal to textoff, or signed integer overflow if smaller. Solution: don't revalidate wp->w_skipcol in that case, as no buffer text is being shown. (Sean Dewar) Don't instead reset w_skipcol; that would lose the scroll position within the line, which may be undesirable if the window is made wider later. Also include changes from the splitmove PR #14042 that I (in my infinite Git wisdom) forgot to commit. This includes a change to Test_window_split_no_room to ensure it doesn't fail for some screen sizes. Move Test_smoothscroll_in_zero_width_window to test_scroll_opt.vim, as that file feels more appropriate. closes: #14068 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 21 Feb 2024 19:45:06 +0100
parents 2f1489b02823
children 8c4339d56b1b
comparison
equal deleted inserted replaced
34388:e7a9e4b8cace 34389:8b0e390b61fe
320 call assert_fails('wincmd L', 'E36:') 320 call assert_fails('wincmd L', 'E36:')
321 call assert_equal(layout, winlayout()) 321 call assert_equal(layout, winlayout())
322 call assert_equal(restcmd, winrestcmd()) 322 call assert_equal(restcmd, winrestcmd())
323 323
324 " Check that the last statusline isn't lost. 324 " Check that the last statusline isn't lost.
325 set laststatus=0 325 " Set its window's width to 2 for the test.
326 let restcmd = winrestcmd()
327 wincmd j 326 wincmd j
327 set laststatus=0 winminwidth=0
328 vertical resize 2
329 set winminwidth&
328 call setwinvar(winnr('k'), '&statusline', '@#') 330 call setwinvar(winnr('k'), '&statusline', '@#')
329 let last_stl_row = win_screenpos(0)[0] - 1 331 let last_stl_row = win_screenpos(0)[0] - 1
330 redraw 332 redraw
331 call assert_equal('@#|', GetScreenStr(last_stl_row)) 333 call assert_equal('@#|', GetScreenStr(last_stl_row))
332 call assert_equal('~ |', GetScreenStr(&lines - &cmdheight)) 334 call assert_equal('~ |', GetScreenStr(&lines - &cmdheight))
335
336 let restcmd = winrestcmd()
333 call assert_fails('wincmd H', 'E36:') 337 call assert_fails('wincmd H', 'E36:')
334 call assert_fails('wincmd L', 'E36:') 338 call assert_fails('wincmd L', 'E36:')
335 call assert_equal(layout, winlayout()) 339 call assert_equal(layout, winlayout())
336 call assert_equal(restcmd, winrestcmd()) 340 call assert_equal(restcmd, winrestcmd())
337 call setwinvar(winnr('k'), '&statusline', '=-') 341 call setwinvar(winnr('k'), '&statusline', '=-')
2151 2155
2152 call assert_equal(wincount, winnr('$')) 2156 call assert_equal(wincount, winnr('$'))
2153 call assert_equal(expand("<cword>"), "'mod'") 2157 call assert_equal(expand("<cword>"), "'mod'")
2154 endfunc 2158 endfunc
2155 2159
2156 func Test_smoothscroll_in_zero_width_window()
2157 set cpo+=n number smoothscroll
2158 set winwidth=99999 winminwidth=0
2159
2160 vsplit
2161 call assert_equal(0, winwidth(winnr('#')))
2162 call win_execute(win_getid(winnr('#')), "norm! \<C-Y>")
2163
2164 only!
2165 set winwidth& winminwidth&
2166 set cpo-=n nonumber nosmoothscroll
2167 endfunc
2168
2169 func Test_splitmove_flatten_frame() 2160 func Test_splitmove_flatten_frame()
2170 split 2161 split
2171 vsplit 2162 vsplit
2172 2163
2173 wincmd L 2164 wincmd L
2177 call assert_equal(winlayout(), layout) 2168 call assert_equal(winlayout(), layout)
2178 2169
2179 only! 2170 only!
2180 endfunc 2171 endfunc
2181 2172
2182 func Test_splitmove_autocmd_window_no_room() 2173 func Test_autocmd_window_force_room()
2183 " Open as many windows as possible 2174 " Open as many windows as possible
2184 while v:true 2175 while v:true
2185 try 2176 try
2186 split 2177 split
2187 catch /E36:/ 2178 catch /E36:/
2204 call assert_fails('wincmd L', 'E36:') 2195 call assert_fails('wincmd L', 'E36:')
2205 2196
2206 edit unload me 2197 edit unload me
2207 enew 2198 enew
2208 bunload! unload\ me 2199 bunload! unload\ me
2209 augroup SplitMoveAucmdWin 2200 augroup AucmdWinForceRoom
2210 au! 2201 au!
2211 au BufEnter * ++once let s:triggered = v:true 2202 au BufEnter * ++once let s:triggered = v:true
2212 \| call assert_equal('autocmd', win_gettype()) 2203 \| call assert_equal('autocmd', win_gettype())
2213 augroup END 2204 augroup END
2214 let layout = winlayout() 2205 let layout = winlayout()
2218 call assert_equal(v:true, s:triggered) 2209 call assert_equal(v:true, s:triggered)
2219 call assert_equal(winlayout(), layout) 2210 call assert_equal(winlayout(), layout)
2220 call assert_equal(winrestcmd(), restcmd) 2211 call assert_equal(winrestcmd(), restcmd)
2221 2212
2222 unlet! s:triggered 2213 unlet! s:triggered
2223 au! SplitMoveAucmdWin 2214 au! AucmdWinForceRoom
2224 augroup! SplitMoveAucmdWin 2215 augroup! AucmdWinForceRoom
2225 %bw! 2216 %bw!
2226 endfunc 2217 endfunc
2227 2218
2228 func Test_win_gotoid_splitmove_textlock_cmdwin() 2219 func Test_win_gotoid_splitmove_textlock_cmdwin()
2229 call setline(1, 'foo') 2220 call setline(1, 'foo')