To: vim_dev@googlegroups.com Subject: Patch 8.2.3400 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3400 Problem: ":z!" is not supported. Solution: Make ":z!" work and add tests. (Dominique Pellé, closes #8836) Use display height instead of current window height. Files: runtime/doc/various.txt, src/ex_cmds.h, src/ex_cmds.c, src/testdir/test_ex_z.vim *** ../vim-8.2.3399/runtime/doc/various.txt 2021-06-20 14:01:25.976924630 +0200 --- runtime/doc/various.txt 2021-09-04 13:37:15.662339363 +0200 *************** *** 170,177 **** If the mark is "=", a line of dashes is printed around the current line. ! :[range]z#[+-^.=][count] *:z#* ! Like ":z", but number the lines. *:=* := [flags] Print the last line number. --- 170,182 ---- If the mark is "=", a line of dashes is printed around the current line. ! *:z! ! :[range]z![+-^.=][count] ! Like ":z:", but when [count] is not specified, it ! defaults to the Vim window height minus one. ! ! :[range]z[!]#[+-^.=][count] *:z#* ! Like ":z" or ":z!", but number the lines. *:=* := [flags] Print the last line number. *************** *** 418,424 **** m *+mzscheme* Mzscheme interface |mzscheme| m *+mzscheme/dyn* Mzscheme interface |mzscheme-dynamic| |/dyn| m *+netbeans_intg* |netbeans| ! *+num64* 64-bit Number support |Number| Always enabled since 8.2.0271, use v:numbersize to check the actual size of a Number. m *+ole* Win32 GUI only: |ole-interface| --- 423,429 ---- m *+mzscheme* Mzscheme interface |mzscheme| m *+mzscheme/dyn* Mzscheme interface |mzscheme-dynamic| |/dyn| m *+netbeans_intg* |netbeans| ! *+num64* 64-bit Number support |Number| Always enabled since 8.2.0271, use v:numbersize to check the actual size of a Number. m *+ole* Win32 GUI only: |ole-interface| *** ../vim-8.2.3399/src/ex_cmds.h 2021-08-02 22:26:52.014701338 +0200 --- src/ex_cmds.h 2021-09-04 13:04:05.554327023 +0200 *************** *** 1824,1830 **** EX_RANGE|EX_WHOLEFOLD|EX_REGSTR|EX_COUNT|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK, ADDR_LINES), EXCMD(CMD_z, "z", ex_z, ! EX_RANGE|EX_WHOLEFOLD|EX_EXTRA|EX_FLAGS|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK, ADDR_LINES), // commands that don't start with a letter --- 1824,1830 ---- EX_RANGE|EX_WHOLEFOLD|EX_REGSTR|EX_COUNT|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK, ADDR_LINES), EXCMD(CMD_z, "z", ex_z, ! EX_RANGE|EX_WHOLEFOLD|EX_BANG|EX_EXTRA|EX_FLAGS|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK, ADDR_LINES), // commands that don't start with a letter *** ../vim-8.2.3399/src/ex_cmds.c 2021-08-21 17:13:08.569405922 +0200 --- src/ex_cmds.c 2021-09-04 13:12:16.543922162 +0200 *************** *** 3445,3451 **** // Vi compatible: ":z!" uses display height, without a count uses // 'scroll' if (eap->forceit) ! bigness = curwin->w_height; else if (!ONE_WINDOW) bigness = curwin->w_height - 3; else --- 3445,3451 ---- // Vi compatible: ":z!" uses display height, without a count uses // 'scroll' if (eap->forceit) ! bigness = Rows - 1; else if (!ONE_WINDOW) bigness = curwin->w_height - 3; else *** ../vim-8.2.3399/src/testdir/test_ex_z.vim 2020-08-12 18:50:31.875655822 +0200 --- src/testdir/test_ex_z.vim 2021-09-04 13:38:29.486049746 +0200 *************** *** 16,23 **** call assert_equal(23, line('.')) let a = execute('20z+3') ! " FIXME: I would expect the same result as '20z3' but it ! " gives "\n21\n22\n23" instead. Bug in Vim or in ":help :z"? "call assert_equal("\n20\n21\n22", a) "call assert_equal(22, line('.')) --- 16,24 ---- call assert_equal(23, line('.')) let a = execute('20z+3') ! " FIXME: I would expect the same result as '20z3' since 'help z' ! " says: Specifying no mark at all is the same as "+". ! " However it " gives "\n21\n22\n23" instead. Bug in Vim or in ":help :z"? "call assert_equal("\n20\n21\n22", a) "call assert_equal(22, line('.')) *************** *** 55,73 **** call assert_equal(100, line('.')) let a = execute('20z-1000') - call assert_match("^\n1\n2\n.*\n19\n20$", a) call assert_equal(20, line('.')) let a = execute('20z=1000') call assert_match("^\n1\n.*\n-\\+\n20\n-\\\+\n.*\n100$", a) call assert_equal(20, line('.')) call assert_fails('20z=a', 'E144:') set window& scroll& bw! endfunc func Test_z_overflow() " This used to access invalid memory as a result of an integer overflow " and freeze vim. --- 56,103 ---- call assert_equal(100, line('.')) let a = execute('20z-1000') call assert_equal(20, line('.')) let a = execute('20z=1000') call assert_match("^\n1\n.*\n-\\+\n20\n-\\\+\n.*\n100$", a) call assert_equal(20, line('.')) + " Tests with multiple windows. + 5split + call setline(1, range(1, 100)) + " Without a count, the number line is window height - 3. + let a = execute('20z') + call assert_equal("\n20\n21", a) + call assert_equal(21, line('.')) + " If window height - 3 is less than 1, it should be clamped to 1. + resize 2 + let a = execute('20z') + call assert_equal("\n20", a) + call assert_equal(20, line('.')) + call assert_fails('20z=a', 'E144:') set window& scroll& bw! endfunc + " :z! is the same as :z but count uses the Vim window height when not specified. + func Test_z_bang() + 4split + call setline(1, range(1, 20)) + + let a = execute('10z!') + call assert_equal("\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20", a) + + let a = execute('10z!#') + 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) + + let a = execute('10z!3') + call assert_equal("\n10\n11\n12", a) + + %bwipe! + endfunc + func Test_z_overflow() " This used to access invalid memory as a result of an integer overflow " and freeze vim. *** ../vim-8.2.3399/src/version.c 2021-09-03 19:21:31.275026040 +0200 --- src/version.c 2021-09-03 19:36:04.741876100 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3400, /**/ -- The fastest way to get an engineer to solve a problem is to declare that the problem is unsolvable. No engineer can walk away from an unsolvable problem until it's solved. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///