diff options
| author | Sean Dewar <6256228+seandewar@users.noreply.github.com> | 2024-03-12 23:05:09 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-12 23:05:09 +0000 |
| commit | 9f59415243adcf70c02bc056ed755859456b20e8 (patch) | |
| tree | 638f689b5225eb4e63c30b2cf15fb549e0780183 /test | |
| parent | dc7ccd6bca81dfa6ade6462a6e30770c63d48266 (diff) | |
| parent | c048beef6c034a46e324fcea7210082d48db32ee (diff) | |
| download | rneovim-9f59415243adcf70c02bc056ed755859456b20e8.tar.gz rneovim-9f59415243adcf70c02bc056ed755859456b20e8.tar.bz2 rneovim-9f59415243adcf70c02bc056ed755859456b20e8.zip | |
Merge pull request #27839 from seandewar/vim-9.1.0169
vim-patch:9.1.{0169,0170,0171,9a660d2883f9}
Diffstat (limited to 'test')
| -rw-r--r-- | test/old/testdir/test_execute_func.vim | 24 | ||||
| -rw-r--r-- | test/old/testdir/test_window_cmd.vim | 99 |
2 files changed, 49 insertions, 74 deletions
diff --git a/test/old/testdir/test_execute_func.vim b/test/old/testdir/test_execute_func.vim index d9909e92a6..ec8ed160c3 100644 --- a/test/old/testdir/test_execute_func.vim +++ b/test/old/testdir/test_execute_func.vim @@ -212,4 +212,28 @@ func Test_execute_cmd_with_null() endif endfunc +func Test_win_execute_tabpagewinnr() + belowright split + tab split + belowright split + call assert_equal(2, tabpagewinnr(1)) + + tabprevious + wincmd p + call assert_equal(1, tabpagenr()) + call assert_equal(1, tabpagewinnr(1)) + call assert_equal(2, tabpagewinnr(2)) + + call win_execute(win_getid(1, 2), + \ 'call assert_equal(2, tabpagenr())' + \ .. '| call assert_equal(1, tabpagewinnr(1))' + \ .. '| call assert_equal(1, tabpagewinnr(2))') + + call assert_equal(1, tabpagenr()) + call assert_equal(1, tabpagewinnr(1)) + call assert_equal(2, tabpagewinnr(2)) + + %bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim index 8898d3a02d..77de5edf8f 100644 --- a/test/old/testdir/test_window_cmd.vim +++ b/test/old/testdir/test_window_cmd.vim @@ -113,64 +113,6 @@ func Test_window_quit() bw Xa Xb endfunc -func Test_window_curwin_not_prevwin() - botright split - call assert_equal(2, winnr()) - call assert_equal(1, winnr('#')) - quit - call assert_equal(1, winnr()) - call assert_equal(0, winnr('#')) - - botright split - botright split - call assert_equal(3, winnr()) - call assert_equal(2, winnr('#')) - 1quit - call assert_equal(2, winnr()) - call assert_equal(1, winnr('#')) - - botright split - call assert_equal(1, tabpagenr()) - call assert_equal(3, winnr()) - call assert_equal(2, winnr('#')) - wincmd T - call assert_equal(2, tabpagenr()) - call assert_equal(1, winnr()) - call assert_equal(0, winnr('#')) - tabfirst - call assert_equal(1, tabpagenr()) - call assert_equal(2, winnr()) - call assert_equal(0, winnr('#')) - - tabonly - botright split - wincmd t - wincmd p - call assert_equal(3, winnr()) - call assert_equal(1, winnr('#')) - quit - call assert_equal(2, winnr()) - call assert_equal(1, winnr('#')) - - botright split - wincmd t - wincmd p - call assert_equal(1, tabpagenr()) - call assert_equal(3, winnr()) - call assert_equal(1, winnr('#')) - wincmd T - call assert_equal(2, tabpagenr()) - call assert_equal(1, winnr()) - call assert_equal(0, winnr('#')) - tabfirst - call assert_equal(1, tabpagenr()) - call assert_equal(2, winnr()) - call assert_equal(1, winnr('#')) - - tabonly - only -endfunc - func Test_window_horizontal_split() call assert_equal(1, winnr('$')) 3wincmd s @@ -258,6 +200,20 @@ func Test_window_split_edit_bufnr() %bw! endfunc +func s:win_layout_info() abort + return #{ + \ layout: winlayout(), + \ pos_sizes: range(1, winnr('$')) + \ ->map({_, nr -> win_getid(nr)->getwininfo()[0]}) + \ ->map({_, wininfo -> #{id: wininfo.winid, + \ row: wininfo.winrow, + \ col: wininfo.wincol, + \ width: wininfo.width, + \ height: wininfo.height}}) + \ ->sort({a, b -> a.id - b.id}) + \ } +endfunc + func Test_window_split_no_room() " N horizontal windows need >= 2*N + 1 lines: " - 1 line + 1 status line in each window @@ -274,12 +230,10 @@ func Test_window_split_no_room() botright vsplit wincmd | - let layout = winlayout() - let restcmd = winrestcmd() + let info = s:win_layout_info() call assert_fails('wincmd J', 'E36:') call assert_fails('wincmd K', 'E36:') - call assert_equal(layout, winlayout()) - call assert_equal(restcmd, winrestcmd()) + call assert_equal(info, s:win_layout_info()) only " N vertical windows need >= 2*(N - 1) + 1 columns: @@ -296,18 +250,18 @@ func Test_window_split_no_room() split wincmd | - let layout = winlayout() - let restcmd = winrestcmd() + let info = s:win_layout_info() call assert_fails('wincmd H', 'E36:') call assert_fails('wincmd L', 'E36:') - call assert_equal(layout, winlayout()) - call assert_equal(restcmd, winrestcmd()) + call assert_equal(info, s:win_layout_info()) " Check that the last statusline isn't lost. " Set its window's width to 2 for the test. wincmd j set laststatus=0 winminwidth=0 vertical resize 2 + " Update expected positions/sizes after the resize. Layout is unchanged. + let info.pos_sizes = s:win_layout_info().pos_sizes set winminwidth& call setwinvar(winnr('k'), '&statusline', '@#') let last_stl_row = win_screenpos(0)[0] - 1 @@ -315,11 +269,9 @@ func Test_window_split_no_room() call assert_equal('@#|', GetScreenStr(last_stl_row)) call assert_equal('~ |', GetScreenStr(&lines - &cmdheight)) - let restcmd = winrestcmd() call assert_fails('wincmd H', 'E36:') call assert_fails('wincmd L', 'E36:') - call assert_equal(layout, winlayout()) - call assert_equal(restcmd, winrestcmd()) + call assert_equal(info, s:win_layout_info()) call setwinvar(winnr('k'), '&statusline', '=-') redraw call assert_equal('=-|', GetScreenStr(last_stl_row)) @@ -1134,6 +1086,7 @@ func Test_win_splitmove() augroup WinSplitMove au! au WinEnter * ++once let s:triggered = v:true + \| call assert_fails('call win_splitmove(winnr(), winnr("$"))', 'E242:') \| call assert_fails('call win_splitmove(winnr("$"), winnr())', 'E242:') augroup END quit @@ -1144,7 +1097,7 @@ func Test_win_splitmove() augroup WinSplitMove au! au BufHidden * ++once let s:triggered = v:true - \| call assert_fails('call win_splitmove(winnr("#"), winnr())', 'E1159:') + \| call assert_fails('call win_splitmove(winnr(), winnr("#"))', 'E1159:') augroup END hide call assert_equal(v:true, s:triggered) @@ -2146,13 +2099,11 @@ func Test_autocmd_window_force_room() au BufEnter * ++once let s:triggered = v:true \| call assert_equal('autocmd', win_gettype()) augroup END - let layout = winlayout() - let restcmd = winrestcmd() + let info = s:win_layout_info() " bufload opening the autocommand window shouldn't give E36. call bufload('unload me') call assert_equal(v:true, s:triggered) - call assert_equal(winlayout(), layout) - call assert_equal(winrestcmd(), restcmd) + call assert_equal(info, s:win_layout_info()) unlet! s:triggered au! AucmdWinForceRoom |