Skip to content

Commit 0dc2fd3

Browse files
yegappanbrammool
authored andcommitted
patch 9.0.0422: not enough testing of the :all command
Problem: Not enough testing of the :all command. Solution: Add more testing. (Yegappan Lakshmanan, closes #11091)
1 parent 5bc1345 commit 0dc2fd3

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

src/testdir/test_arglist.vim

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,4 +610,130 @@ func Test_clear_arglist_in_all()
610610
au! *
611611
endfunc
612612

613+
" Test for the :all command
614+
func Test_all_command()
615+
%argdelete
616+
617+
" :all command should not close windows with files in the argument list,
618+
" but can rearrange the windows.
619+
args Xargnew1 Xargnew2
620+
%bw!
621+
edit Xargold1
622+
split Xargnew1
623+
let Xargnew1_winid = win_getid()
624+
split Xargold2
625+
split Xargnew2
626+
let Xargnew2_winid = win_getid()
627+
split Xargold3
628+
all
629+
call assert_equal(2, winnr('$'))
630+
call assert_equal([Xargnew1_winid, Xargnew2_winid],
631+
\ [win_getid(1), win_getid(2)])
632+
call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2')],
633+
\ [winbufnr(1), winbufnr(2)])
634+
635+
" :all command should close windows for files which are not in the
636+
" argument list in the current tab page.
637+
%bw!
638+
edit Xargold1
639+
split Xargold2
640+
tabedit Xargold3
641+
split Xargold4
642+
tabedit Xargold5
643+
tabfirst
644+
all
645+
call assert_equal(3, tabpagenr('$'))
646+
call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2')], tabpagebuflist(1))
647+
call assert_equal([bufnr('Xargold4'), bufnr('Xargold3')], tabpagebuflist(2))
648+
call assert_equal([bufnr('Xargold5')], tabpagebuflist(3))
649+
650+
" :tab all command should close windows for files which are not in the
651+
" argument list across all the tab pages.
652+
%bw!
653+
edit Xargold1
654+
split Xargold2
655+
tabedit Xargold3
656+
split Xargold4
657+
tabedit Xargold5
658+
tabfirst
659+
args Xargnew1 Xargnew2
660+
tab all
661+
call assert_equal(2, tabpagenr('$'))
662+
call assert_equal([bufnr('Xargnew1')], tabpagebuflist(1))
663+
call assert_equal([bufnr('Xargnew2')], tabpagebuflist(2))
664+
665+
" If a count is specified, then :all should open only that many windows.
666+
%bw!
667+
args Xargnew1 Xargnew2 Xargnew3 Xargnew4 Xargnew5
668+
all 3
669+
call assert_equal(3, winnr('$'))
670+
call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2'), bufnr('Xargnew3')],
671+
\ [winbufnr(1), winbufnr(2), winbufnr(3)])
672+
673+
" The :all command should not open more than 'tabpagemax' tab pages.
674+
" If there are more files, then they should be opened in the last tab page.
675+
%bw!
676+
set tabpagemax=3
677+
tab all
678+
call assert_equal(3, tabpagenr('$'))
679+
call assert_equal([bufnr('Xargnew1')], tabpagebuflist(1))
680+
call assert_equal([bufnr('Xargnew2')], tabpagebuflist(2))
681+
call assert_equal([bufnr('Xargnew3'), bufnr('Xargnew4'), bufnr('Xargnew5')],
682+
\ tabpagebuflist(3))
683+
set tabpagemax&
684+
685+
" Without the 'hidden' option, modified buffers should not be closed.
686+
args Xargnew1 Xargnew2
687+
%bw!
688+
edit Xargtemp1
689+
call setline(1, 'temp buffer 1')
690+
split Xargtemp2
691+
call setline(1, 'temp buffer 2')
692+
all
693+
call assert_equal(4, winnr('$'))
694+
call assert_equal([bufnr('Xargtemp2'), bufnr('Xargtemp1'), bufnr('Xargnew1'),
695+
\ bufnr('Xargnew2')],
696+
\ [winbufnr(1), winbufnr(2), winbufnr(3), winbufnr(4)])
697+
698+
" With the 'hidden' option set, both modified and unmodified buffers in
699+
" closed windows should be hidden.
700+
set hidden
701+
all
702+
call assert_equal(2, winnr('$'))
703+
call assert_equal([bufnr('Xargnew1'), bufnr('Xargnew2')],
704+
\ [winbufnr(1), winbufnr(2)])
705+
call assert_equal([1, 1, 0, 0], [getbufinfo('Xargtemp1')[0].hidden,
706+
\ getbufinfo('Xargtemp2')[0].hidden,
707+
\ getbufinfo('Xargnew1')[0].hidden,
708+
\ getbufinfo('Xargnew2')[0].hidden])
709+
set nohidden
710+
711+
" When 'winheight' is set to a large value, :all should open only one
712+
" window.
713+
args Xargnew1 Xargnew2 Xargnew3 Xargnew4 Xargnew5
714+
%bw!
715+
set winheight=9999
716+
call assert_fails('all', 'E36:')
717+
call assert_equal([1, bufnr('Xargnew1')], [winnr('$'), winbufnr(1)])
718+
set winheight&
719+
720+
" When 'winwidth' is set to a large value, :vert all should open only one
721+
" window.
722+
%bw!
723+
set winwidth=9999
724+
call assert_fails('vert all', 'E36:')
725+
call assert_equal([1, bufnr('Xargnew1')], [winnr('$'), winbufnr(1)])
726+
set winwidth&
727+
728+
" empty argument list tests
729+
%bw!
730+
%argdelete
731+
call assert_equal('', execute('args'))
732+
all
733+
call assert_equal(1, winnr('$'))
734+
735+
%argdelete
736+
%bw!
737+
endfunc
738+
613739
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ static char *(features[]) =
703703

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
422,
706708
/**/
707709
421,
708710
/**/

0 commit comments

Comments
 (0)