Patch 8.2.1061
Problem: Insufficient testing for src/window.c.
Solution: Add more tests. (Yegappan Lakshmanan, closes #6345)
Files: src/testdir/test_excmd.vim, src/testdir/test_gf.vim,
src/testdir/test_options.vim, src/testdir/test_popupwin.vim,
src/testdir/test_quickfix.vim, src/testdir/test_tabpage.vim,
src/testdir/test_tagjump.vim, src/testdir/test_window_cmd.vim,
src/window.c
*** ../vim-8.2.1060/src/testdir/test_excmd.vim 2020-04-21 22:01:11.089499502 +0200
--- src/testdir/test_excmd.vim 2020-06-26 20:36:21.041722218 +0200
***************
*** 371,376 ****
--- 371,381 ----
close
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
" Test for the :verbose command
*** ../vim-8.2.1060/src/testdir/test_gf.vim 2020-06-22 21:34:24.331583419 +0200
--- src/testdir/test_gf.vim 2020-06-26 20:36:21.045722207 +0200
***************
*** 74,84 ****
call assert_equal('Xfile', bufname('%'))
call assert_equal(2, getcurpos()[1])
set isfname&
call delete('Xfile')
call delete('Xfile2')
! bwipe Xfile
! bwipe Xfile2
endfunc
" Test for invoking 'gf' on a ${VAR} variable
--- 74,91 ----
call assert_equal('Xfile', bufname('%'))
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&
call delete('Xfile')
call delete('Xfile2')
! %bw!
endfunc
" Test for invoking 'gf' on a ${VAR} variable
*** ../vim-8.2.1060/src/testdir/test_options.vim 2020-06-22 21:34:24.335583405 +0200
--- src/testdir/test_options.vim 2020-06-26 20:36:21.045722207 +0200
***************
*** 953,956 ****
--- 953,976 ----
set window&
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-8.2.1060/src/testdir/test_popupwin.vim 2020-06-22 20:22:15.679211788 +0200
--- src/testdir/test_popupwin.vim 2020-06-26 20:36:21.045722207 +0200
***************
*** 945,950 ****
--- 945,952 ----
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, "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 w")', 'E994:')
call assert_fails('call win_execute(winid, "wincmd t")', 'E994:')
*** ../vim-8.2.1060/src/testdir/test_quickfix.vim 2020-06-22 21:34:24.335583405 +0200
--- src/testdir/test_quickfix.vim 2020-06-26 20:36:21.045722207 +0200
***************
*** 286,291 ****
--- 286,308 ----
call assert_equal(12, winwidth(0))
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'
" Opening the quickfix window in multiple tab pages should reuse the
" quickfix buffer
*** ../vim-8.2.1060/src/testdir/test_tabpage.vim 2020-06-21 13:23:42.063290853 +0200
--- src/testdir/test_tabpage.vim 2020-06-26 20:36:21.045722207 +0200
***************
*** 143,148 ****
--- 143,150 ----
call assert_fails("tabmove $3", 'E474:')
call assert_fails("%tabonly", 'E16:')
1tabonly!
+ tabmove 1
+ call assert_equal(1, tabpagenr())
tabnew
call assert_fails("-2tabmove", 'E474:')
tabonly!
***************
*** 712,715 ****
--- 714,780 ----
%bw!
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-8.2.1060/src/testdir/test_tagjump.vim 2020-06-20 16:05:29.016185239 +0200
--- src/testdir/test_tagjump.vim 2020-06-26 20:36:21.045722207 +0200
***************
*** 12,17 ****
--- 12,58 ----
set tagstack&vim
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()
CheckFeature quickfix
***************
*** 1267,1272 ****
--- 1308,1317 ----
close
call assert_fails('3wincmd d', 'E387:')
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
dsplit FOO
*** ../vim-8.2.1060/src/testdir/test_window_cmd.vim 2020-04-26 15:59:51.206952132 +0200
--- src/testdir/test_window_cmd.vim 2020-06-26 20:36:21.049722194 +0200
***************
*** 36,42 ****
set ls&vim
endfunc
! function Test_window_cmd_wincmd_gf()
let fname = 'test_gf.txt'
let swp_fname = '.' . fname . '.swp'
call writefile([], fname)
--- 36,51 ----
set ls&vim
endfunc
! " 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 swp_fname = '.' . fname . '.swp'
call writefile([], fname)
***************
*** 1099,1102 ****
--- 1108,1286 ----
call assert_beeps("normal \<C-W>2gt")
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-8.2.1060/src/window.c 2020-06-26 19:44:02.972305916 +0200
--- src/window.c 2020-06-26 20:36:21.053722184 +0200
***************
*** 1810,1817 ****
return;
}
! // may need move the status line/vertical separator of the last window
! //
if (win1 == lastwin)
{
height = win1->w_prev->w_status_height;
--- 1810,1817 ----
return;
}
! // may need to move the status line/vertical separator of the last
! // window
if (win1 == lastwin)
{
height = win1->w_prev->w_status_height;
*** ../vim-8.2.1060/src/version.c 2020-06-26 20:23:40.203927534 +0200
--- src/version.c 2020-06-26 20:37:25.333542098 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1061,
/**/
--
No man may purchase alcohol without written consent from his wife.
[real standing law in Pennsylvania, United States of America]
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///