mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.1061: insufficient testing for src/window.c
Problem: Insufficient testing for src/window.c. Solution: Add more tests. (Yegappan Lakshmanan, closes #6345)
This commit is contained in:
@@ -371,6 +371,11 @@ func Test_run_excmd_with_text_locked()
|
|||||||
close
|
close
|
||||||
|
|
||||||
call assert_fails("call feedkeys(\":\<C-R>=execute('bnext')\<CR>\", 'xt')", 'E565:')
|
call assert_fails("call feedkeys(\":\<C-R>=execute('bnext')\<CR>\", 'xt')", 'E565:')
|
||||||
|
|
||||||
|
" :tabfirst
|
||||||
|
tabnew
|
||||||
|
call assert_fails("call feedkeys(\":\<C-R>=execute('tabfirst')\<CR>\", 'xt')", 'E565:')
|
||||||
|
tabclose
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for the :verbose command
|
" Test for the :verbose command
|
||||||
|
@@ -74,11 +74,18 @@ func Test_gF()
|
|||||||
call assert_equal('Xfile', bufname('%'))
|
call assert_equal('Xfile', bufname('%'))
|
||||||
call assert_equal(2, getcurpos()[1])
|
call assert_equal(2, getcurpos()[1])
|
||||||
|
|
||||||
|
" jumping to the file/line with CTRL-W_F
|
||||||
|
%bw!
|
||||||
|
edit Xfile1
|
||||||
|
call setline(1, ['one', 'Xfile:4', 'three'])
|
||||||
|
exe "normal 2G\<C-W>F"
|
||||||
|
call assert_equal('Xfile', bufname('%'))
|
||||||
|
call assert_equal(4, getcurpos()[1])
|
||||||
|
|
||||||
set isfname&
|
set isfname&
|
||||||
call delete('Xfile')
|
call delete('Xfile')
|
||||||
call delete('Xfile2')
|
call delete('Xfile2')
|
||||||
bwipe Xfile
|
%bw!
|
||||||
bwipe Xfile2
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for invoking 'gf' on a ${VAR} variable
|
" Test for invoking 'gf' on a ${VAR} variable
|
||||||
|
@@ -953,4 +953,24 @@ func Test_window_opt()
|
|||||||
set window&
|
set window&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for the 'winminheight' option
|
||||||
|
func Test_opt_winminheight()
|
||||||
|
only!
|
||||||
|
let &winheight = &lines + 4
|
||||||
|
call assert_fails('let &winminheight = &lines + 2', 'E36:')
|
||||||
|
call assert_true(&winminheight <= &lines)
|
||||||
|
set winminheight&
|
||||||
|
set winheight&
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for the 'winminwidth' option
|
||||||
|
func Test_opt_winminwidth()
|
||||||
|
only!
|
||||||
|
let &winwidth = &columns + 4
|
||||||
|
call assert_fails('let &winminwidth = &columns + 2', 'E36:')
|
||||||
|
call assert_true(&winminwidth <= &columns)
|
||||||
|
set winminwidth&
|
||||||
|
set winwidth&
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -945,6 +945,8 @@ func Test_win_execute_not_allowed()
|
|||||||
call assert_fails('call win_execute(winid, "blast")', 'E994:')
|
call assert_fails('call win_execute(winid, "blast")', 'E994:')
|
||||||
call assert_fails('call win_execute(winid, "edit")', 'E994:')
|
call assert_fails('call win_execute(winid, "edit")', 'E994:')
|
||||||
call assert_fails('call win_execute(winid, "enew")', 'E994:')
|
call assert_fails('call win_execute(winid, "enew")', 'E994:')
|
||||||
|
call assert_fails('call win_execute(winid, "help")', 'E994:')
|
||||||
|
call assert_fails('call win_execute(winid, "1only")', 'E994:')
|
||||||
call assert_fails('call win_execute(winid, "wincmd x")', 'E994:')
|
call assert_fails('call win_execute(winid, "wincmd x")', 'E994:')
|
||||||
call assert_fails('call win_execute(winid, "wincmd w")', 'E994:')
|
call assert_fails('call win_execute(winid, "wincmd w")', 'E994:')
|
||||||
call assert_fails('call win_execute(winid, "wincmd t")', 'E994:')
|
call assert_fails('call win_execute(winid, "wincmd t")', 'E994:')
|
||||||
|
@@ -286,6 +286,23 @@ func XwindowTests(cchar)
|
|||||||
call assert_equal(12, winwidth(0))
|
call assert_equal(12, winwidth(0))
|
||||||
Xclose
|
Xclose
|
||||||
|
|
||||||
|
" Horizontally or vertically splitting the quickfix window should create a
|
||||||
|
" normal window/buffer
|
||||||
|
Xopen
|
||||||
|
wincmd s
|
||||||
|
call assert_equal(0, getwininfo(win_getid())[0].quickfix)
|
||||||
|
call assert_equal(0, getwininfo(win_getid())[0].loclist)
|
||||||
|
call assert_notequal('quickfix', &buftype)
|
||||||
|
close
|
||||||
|
Xopen
|
||||||
|
wincmd v
|
||||||
|
call assert_equal(0, getwininfo(win_getid())[0].quickfix)
|
||||||
|
call assert_equal(0, getwininfo(win_getid())[0].loclist)
|
||||||
|
call assert_notequal('quickfix', &buftype)
|
||||||
|
close
|
||||||
|
Xopen
|
||||||
|
Xclose
|
||||||
|
|
||||||
if a:cchar == 'c'
|
if a:cchar == 'c'
|
||||||
" Opening the quickfix window in multiple tab pages should reuse the
|
" Opening the quickfix window in multiple tab pages should reuse the
|
||||||
" quickfix buffer
|
" quickfix buffer
|
||||||
|
@@ -143,6 +143,8 @@ function Test_tabpage()
|
|||||||
call assert_fails("tabmove $3", 'E474:')
|
call assert_fails("tabmove $3", 'E474:')
|
||||||
call assert_fails("%tabonly", 'E16:')
|
call assert_fails("%tabonly", 'E16:')
|
||||||
1tabonly!
|
1tabonly!
|
||||||
|
tabmove 1
|
||||||
|
call assert_equal(1, tabpagenr())
|
||||||
tabnew
|
tabnew
|
||||||
call assert_fails("-2tabmove", 'E474:')
|
call assert_fails("-2tabmove", 'E474:')
|
||||||
tabonly!
|
tabonly!
|
||||||
@@ -712,4 +714,67 @@ func Test_tabline_tabmenu()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for changing the current tab page from an autocmd when closing a tab
|
||||||
|
" page.
|
||||||
|
func Test_tabpage_switchtab_on_close()
|
||||||
|
only
|
||||||
|
tabnew
|
||||||
|
tabnew
|
||||||
|
" Test for BufLeave
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
au BufLeave * tabfirst
|
||||||
|
augroup END
|
||||||
|
tabclose
|
||||||
|
call assert_equal(1, tabpagenr())
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" Test for WinLeave
|
||||||
|
$tabnew
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
au WinLeave * tabfirst
|
||||||
|
augroup END
|
||||||
|
tabclose
|
||||||
|
call assert_equal(1, tabpagenr())
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" Test for TabLeave
|
||||||
|
$tabnew
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
au TabLeave * tabfirst
|
||||||
|
augroup END
|
||||||
|
tabclose
|
||||||
|
call assert_equal(1, tabpagenr())
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
augroup! T1
|
||||||
|
tabonly
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for closing the destination tabpage when jumping from one to another.
|
||||||
|
func Test_tabpage_close_on_switch()
|
||||||
|
tabnew
|
||||||
|
tabnew
|
||||||
|
edit Xfile
|
||||||
|
augroup T2
|
||||||
|
au!
|
||||||
|
au BufLeave Xfile 1tabclose
|
||||||
|
augroup END
|
||||||
|
tabfirst
|
||||||
|
call assert_equal(2, tabpagenr())
|
||||||
|
call assert_equal('Xfile', @%)
|
||||||
|
augroup T2
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
augroup! T2
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -12,6 +12,47 @@ func Test_ptag_with_notagstack()
|
|||||||
set tagstack&vim
|
set tagstack&vim
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_ptjump()
|
||||||
|
CheckFeature quickfix
|
||||||
|
|
||||||
|
set tags=Xtags
|
||||||
|
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||||
|
\ "one\tXfile\t1",
|
||||||
|
\ "three\tXfile\t3",
|
||||||
|
\ "two\tXfile\t2"],
|
||||||
|
\ 'Xtags')
|
||||||
|
call writefile(['one', 'two', 'three'], 'Xfile')
|
||||||
|
|
||||||
|
%bw!
|
||||||
|
ptjump two
|
||||||
|
call assert_equal(2, winnr())
|
||||||
|
wincmd p
|
||||||
|
call assert_equal(1, &previewwindow)
|
||||||
|
call assert_equal('Xfile', expand("%:p:t"))
|
||||||
|
call assert_equal(2, line('.'))
|
||||||
|
call assert_equal(2, winnr('$'))
|
||||||
|
call assert_equal(1, winnr())
|
||||||
|
close
|
||||||
|
call setline(1, ['one', 'two', 'three'])
|
||||||
|
exe "normal 3G\<C-W>g}"
|
||||||
|
call assert_equal(2, winnr())
|
||||||
|
wincmd p
|
||||||
|
call assert_equal(1, &previewwindow)
|
||||||
|
call assert_equal('Xfile', expand("%:p:t"))
|
||||||
|
call assert_equal(3, line('.'))
|
||||||
|
call assert_equal(2, winnr('$'))
|
||||||
|
call assert_equal(1, winnr())
|
||||||
|
close
|
||||||
|
exe "normal 3G5\<C-W>\<C-G>}"
|
||||||
|
wincmd p
|
||||||
|
call assert_equal(5, winheight(0))
|
||||||
|
close
|
||||||
|
|
||||||
|
call delete('Xtags')
|
||||||
|
call delete('Xfile')
|
||||||
|
set tags&
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_cancel_ptjump()
|
func Test_cancel_ptjump()
|
||||||
CheckFeature quickfix
|
CheckFeature quickfix
|
||||||
|
|
||||||
@@ -1267,6 +1308,10 @@ func Test_macro_search()
|
|||||||
close
|
close
|
||||||
call assert_fails('3wincmd d', 'E387:')
|
call assert_fails('3wincmd d', 'E387:')
|
||||||
call assert_fails('6wincmd d', 'E388:')
|
call assert_fails('6wincmd d', 'E388:')
|
||||||
|
new
|
||||||
|
call assert_fails("normal \<C-W>d", 'E349:')
|
||||||
|
call assert_fails("normal \<C-W>\<C-D>", 'E349:')
|
||||||
|
close
|
||||||
|
|
||||||
" Test for :dsplit
|
" Test for :dsplit
|
||||||
dsplit FOO
|
dsplit FOO
|
||||||
|
@@ -36,7 +36,16 @@ func Test_window_cmd_cmdwin_with_vsp()
|
|||||||
set ls&vim
|
set ls&vim
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Test_window_cmd_wincmd_gf()
|
" Test for jumping to windows
|
||||||
|
func Test_window_jump()
|
||||||
|
new
|
||||||
|
" jumping to a window with a count greater than the max windows
|
||||||
|
exe "normal 4\<C-W>w"
|
||||||
|
call assert_equal(2, winnr())
|
||||||
|
only
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_window_cmd_wincmd_gf()
|
||||||
let fname = 'test_gf.txt'
|
let fname = 'test_gf.txt'
|
||||||
let swp_fname = '.' . fname . '.swp'
|
let swp_fname = '.' . fname . '.swp'
|
||||||
call writefile([], fname)
|
call writefile([], fname)
|
||||||
@@ -1099,4 +1108,179 @@ func Test_wincmd_fails()
|
|||||||
call assert_beeps("normal \<C-W>2gt")
|
call assert_beeps("normal \<C-W>2gt")
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for adjusting the window width when a window is closed with some
|
||||||
|
" windows using 'winfixwidth'
|
||||||
|
func Test_window_width_adjust()
|
||||||
|
only
|
||||||
|
" Three vertical windows. Windows 1 and 2 have 'winfixwidth' set and close
|
||||||
|
" window 2.
|
||||||
|
wincmd v
|
||||||
|
vert resize 10
|
||||||
|
set winfixwidth
|
||||||
|
wincmd v
|
||||||
|
set winfixwidth
|
||||||
|
wincmd c
|
||||||
|
call assert_inrange(10, 12, winwidth(1))
|
||||||
|
" Three vertical windows. Windows 2 and 3 have 'winfixwidth' set and close
|
||||||
|
" window 3.
|
||||||
|
only
|
||||||
|
set winfixwidth
|
||||||
|
wincmd v
|
||||||
|
vert resize 10
|
||||||
|
set winfixwidth
|
||||||
|
wincmd v
|
||||||
|
set nowinfixwidth
|
||||||
|
wincmd b
|
||||||
|
wincmd c
|
||||||
|
call assert_inrange(10, 12, winwidth(2))
|
||||||
|
|
||||||
|
new | only
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for jumping to a vertical/horizontal neighbor window based on the
|
||||||
|
" current cursor position
|
||||||
|
func Test_window_goto_neightbor()
|
||||||
|
%bw!
|
||||||
|
|
||||||
|
" Vertical window movement
|
||||||
|
|
||||||
|
" create the following window layout:
|
||||||
|
" +--+--+
|
||||||
|
" |w1|w3|
|
||||||
|
" +--+ |
|
||||||
|
" |w2| |
|
||||||
|
" +--+--+
|
||||||
|
" |w4 |
|
||||||
|
" +-----+
|
||||||
|
new
|
||||||
|
vsplit
|
||||||
|
split
|
||||||
|
" vertically jump from w4
|
||||||
|
wincmd b
|
||||||
|
call setline(1, repeat(' ', &columns))
|
||||||
|
call cursor(1, 1)
|
||||||
|
wincmd k
|
||||||
|
call assert_equal(2, winnr())
|
||||||
|
wincmd b
|
||||||
|
call cursor(1, &columns)
|
||||||
|
redraw!
|
||||||
|
wincmd k
|
||||||
|
call assert_equal(3, winnr())
|
||||||
|
%bw!
|
||||||
|
|
||||||
|
" create the following window layout:
|
||||||
|
" +--+--+--+
|
||||||
|
" |w1|w2|w3|
|
||||||
|
" +--+--+--+
|
||||||
|
" |w4 |
|
||||||
|
" +--------+
|
||||||
|
new
|
||||||
|
vsplit
|
||||||
|
vsplit
|
||||||
|
wincmd b
|
||||||
|
call setline(1, repeat(' ', &columns))
|
||||||
|
call cursor(1, 1)
|
||||||
|
wincmd k
|
||||||
|
call assert_equal(1, winnr())
|
||||||
|
wincmd b
|
||||||
|
call cursor(1, &columns / 2)
|
||||||
|
redraw!
|
||||||
|
wincmd k
|
||||||
|
call assert_equal(2, winnr())
|
||||||
|
wincmd b
|
||||||
|
call cursor(1, &columns)
|
||||||
|
redraw!
|
||||||
|
wincmd k
|
||||||
|
call assert_equal(3, winnr())
|
||||||
|
%bw!
|
||||||
|
|
||||||
|
" Horizontal window movement
|
||||||
|
|
||||||
|
" create the following window layout:
|
||||||
|
" +--+--+--+
|
||||||
|
" |w1|w2|w4|
|
||||||
|
" +--+--+ |
|
||||||
|
" |w3 | |
|
||||||
|
" +-----+--+
|
||||||
|
vsplit
|
||||||
|
split
|
||||||
|
vsplit
|
||||||
|
4wincmd l
|
||||||
|
call setline(1, repeat([' '], &lines))
|
||||||
|
call cursor(1, 1)
|
||||||
|
redraw!
|
||||||
|
wincmd h
|
||||||
|
call assert_equal(2, winnr())
|
||||||
|
4wincmd l
|
||||||
|
call cursor(&lines, 1)
|
||||||
|
redraw!
|
||||||
|
wincmd h
|
||||||
|
call assert_equal(3, winnr())
|
||||||
|
%bw!
|
||||||
|
|
||||||
|
" create the following window layout:
|
||||||
|
" +--+--+
|
||||||
|
" |w1|w4|
|
||||||
|
" +--+ +
|
||||||
|
" |w2| |
|
||||||
|
" +--+ +
|
||||||
|
" |w3| |
|
||||||
|
" +--+--+
|
||||||
|
vsplit
|
||||||
|
split
|
||||||
|
split
|
||||||
|
wincmd l
|
||||||
|
call setline(1, repeat([' '], &lines))
|
||||||
|
call cursor(1, 1)
|
||||||
|
redraw!
|
||||||
|
wincmd h
|
||||||
|
call assert_equal(1, winnr())
|
||||||
|
wincmd l
|
||||||
|
call cursor(&lines / 2, 1)
|
||||||
|
redraw!
|
||||||
|
wincmd h
|
||||||
|
call assert_equal(2, winnr())
|
||||||
|
wincmd l
|
||||||
|
call cursor(&lines, 1)
|
||||||
|
redraw!
|
||||||
|
wincmd h
|
||||||
|
call assert_equal(3, winnr())
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for an autocmd closing the destination window when jumping from one
|
||||||
|
" window to another.
|
||||||
|
func Test_close_dest_window()
|
||||||
|
split
|
||||||
|
edit Xfile
|
||||||
|
|
||||||
|
" Test for BufLeave
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
au BufLeave Xfile $wincmd c
|
||||||
|
augroup END
|
||||||
|
wincmd b
|
||||||
|
call assert_equal(1, winnr('$'))
|
||||||
|
call assert_equal('Xfile', @%)
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" Test for WinLeave
|
||||||
|
new
|
||||||
|
wincmd p
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
au WinLeave * 1wincmd c
|
||||||
|
augroup END
|
||||||
|
wincmd t
|
||||||
|
call assert_equal(1, winnr('$'))
|
||||||
|
call assert_equal('Xfile', @%)
|
||||||
|
augroup T1
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
augroup! T1
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1061,
|
||||||
/**/
|
/**/
|
||||||
1060,
|
1060,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1810,8 +1810,8 @@ win_move_after(win_T *win1, win_T *win2)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// may need move the status line/vertical separator of the last window
|
// may need to move the status line/vertical separator of the last
|
||||||
//
|
// window
|
||||||
if (win1 == lastwin)
|
if (win1 == lastwin)
|
||||||
{
|
{
|
||||||
height = win1->w_prev->w_status_height;
|
height = win1->w_prev->w_status_height;
|
||||||
|
Reference in New Issue
Block a user