@@ -16,8 +16,9 @@ func Test_z()
1616 call assert_equal (23 , line (' .' ))
1717
1818 let a = execute (' 20z+3' )
19- " FIXME: I would expect the same result as '20z3' but it
20- " gives "\n21\n22\n23" instead. Bug in Vim or in ":help :z"?
19+ " FIXME: I would expect the same result as '20z3' since 'help z'
20+ " says: Specifying no mark at all is the same as "+".
21+ " However it " gives "\n21\n22\n23" instead. Bug in Vim or in ":help :z"?
2122 " call assert_equal("\n20\n21\n22", a)
2223 " call assert_equal(22, line('.'))
2324
@@ -55,19 +56,48 @@ func Test_z()
5556 call assert_equal (100 , line (' .' ))
5657
5758 let a = execute (' 20z-1000' )
58- call assert_match (" ^\n 1\n 2\n .*\n 19\n 20$" , a )
5959 call assert_equal (20 , line (' .' ))
6060
6161 let a = execute (' 20z=1000' )
6262 call assert_match (" ^\n 1\n .*\n -\\ +\n 20\n -\\ \+ \n .*\n 100$" , a )
6363 call assert_equal (20 , line (' .' ))
6464
65+ " Tests with multiple windows.
66+ 5 split
67+ call setline (1 , range (1 , 100 ))
68+ " Without a count, the number line is window height - 3.
69+ let a = execute (' 20z' )
70+ call assert_equal (" \n 20\n 21" , a )
71+ call assert_equal (21 , line (' .' ))
72+ " If window height - 3 is less than 1, it should be clamped to 1.
73+ resize 2
74+ let a = execute (' 20z' )
75+ call assert_equal (" \n 20" , a )
76+ call assert_equal (20 , line (' .' ))
77+
6578 call assert_fails (' 20z=a' , ' E144:' )
6679
6780 set window & scroll &
6881 bw !
6982endfunc
7083
84+ " :z! is the same as :z but count uses the Vim window height when not specified.
85+ func Test_z_bang ()
86+ 4 split
87+ call setline (1 , range (1 , 20 ))
88+
89+ let a = execute (' 10z!' )
90+ call assert_equal (" \n 10\n 11\n 12\n 13\n 14\n 15\n 16\n 17\n 18\n 19\n 20" , a )
91+
92+ let a = execute (' 10z!#' )
93+ call assert_equal (" \n 10 10\n 11 11\n 12 12\n 13 13\n 14 14\n 15 15\n 16 16\n 17 17\n 18 18\n 19 19\n 20 20" , a )
94+
95+ let a = execute (' 10z!3' )
96+ call assert_equal (" \n 10\n 11\n 12" , a )
97+
98+ % bwipe!
99+ endfunc
100+
71101func Test_z_overflow ()
72102 " This used to access invalid memory as a result of an integer overflow
73103 " and freeze vim.
0 commit comments