aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSean Dewar <6256228+seandewar@users.noreply.github.com>2024-03-12 21:19:18 +0000
committerSean Dewar <6256228+seandewar@users.noreply.github.com>2024-03-12 21:38:39 +0000
commit6bbb02d9ba76551dd4856ad50a237e92c678702d (patch)
tree2714dd51a7a70e586b0b51d0094a2f86fafa3959 /test
parentca7b603d02ecd1ed4098f487cd01acd470ca6a74 (diff)
downloadrneovim-6bbb02d9ba76551dd4856ad50a237e92c678702d.tar.gz
rneovim-6bbb02d9ba76551dd4856ad50a237e92c678702d.tar.bz2
rneovim-6bbb02d9ba76551dd4856ad50a237e92c678702d.zip
vim-patch:9.1.0171: Small split-move related improvements
Problem: small improvements can be made to split-move related functions. Solution: apply them (Sean Dewar): Some of these changes were already applied to Nvim. Here are the ones which were missing: - Improve some doc comments (frame_flatten should still work for non-current tabpages, despite the topframe check, which looks benign, though I'm unsure if it's still needed; see vim/vim#2467). - f_win_splitmove should check_split_disallowed on wp, not targetwin, as that's what win_splitmove checks (though it's probably unnecessary to check b_locked_split at all; see vim/vim#14109, which I hope to get around to finishing at some point). - Apply the winframe_restore comment changes, and remove win_comp_pos from after winframe_restore in win_splitmove, as it shouldn't be necessary (no need to remove it from nvim_win_set_config too, as it was already omitted). Move win_append after winframe_restore in win_splitmove to match Vim. closes: vim/vim#14185 https://github.com/vim/vim/commit/5cac1a9bee0798d70a7fd80363a1f697759638e8
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_window_cmd.vim41
1 files changed, 25 insertions, 16 deletions
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
index 9c34c15ff8..77de5edf8f 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -200,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
@@ -216,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:
@@ -238,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
@@ -257,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))
@@ -1076,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
@@ -1086,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)
@@ -2088,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