To: vim_dev@googlegroups.com Subject: Patch 8.2.0023 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0023 Problem: Command line editing not sufficiently tested. Solution: Add more tests. (Dominique Pelle, closes #5374) Files: src/testdir/Make_all.mak, src/testdir/test_alot.vim, src/testdir/test_cmdline.vim, src/testdir/test_ex_mode.vim *** ../vim-8.2.0022/src/testdir/Make_all.mak 2019-12-16 22:43:22.324823401 +0100 --- src/testdir/Make_all.mak 2019-12-18 22:22:37.487198788 +0100 *************** *** 97,102 **** --- 97,103 ---- test_ex_equal \ test_ex_undo \ test_ex_z \ + test_ex_mode \ test_excmd \ test_exec_while_if \ test_execute_func \ *** ../vim-8.2.0022/src/testdir/test_alot.vim 2019-11-06 15:19:09.000000000 +0100 --- src/testdir/test_alot.vim 2019-12-18 22:22:37.487198788 +0100 *************** *** 13,18 **** --- 13,19 ---- source test_ex_equal.vim source test_ex_undo.vim source test_ex_z.vim + source test_ex_mode.vim source test_execute_func.vim source test_expand.vim source test_expand_dllpath.vim *** ../vim-8.2.0022/src/testdir/test_cmdline.vim 2019-12-05 18:12:17.000000000 +0100 --- src/testdir/test_cmdline.vim 2019-12-18 22:22:37.487198788 +0100 *************** *** 419,425 **** call delete('a', 'rf') endfunc ! func Test_paste_in_cmdline() let @a = "def" call feedkeys(":abc \a ghi\\"\", 'tx') call assert_equal('"abc def ghi', @:) --- 419,425 ---- call delete('a', 'rf') endfunc ! func Test_cmdline_paste() let @a = "def" call feedkeys(":abc \a ghi\\"\", 'tx') call assert_equal('"abc def ghi', @:) *************** *** 459,476 **** bwipe! endfunc ! func Test_remove_char_in_cmdline() ! call feedkeys(":abc def\\\\"\", 'tx') ! call assert_equal('"abc ef', @:) ! call feedkeys(":abc def\\\\"\", 'tx') ! call assert_equal('"abcdef', @:) ! call feedkeys(":abc def ghi\\\\"\", 'tx') ! call assert_equal('"abc ghi', @:) ! call feedkeys(":abc def\\\\"\", 'tx') ! call assert_equal('"def', @:) endfunc func Test_illegal_address1() --- 459,495 ---- bwipe! endfunc ! func Test_cmdline_remove_char() ! let encoding_save = &encoding ! ! for e in ['utf8', 'latin1'] ! exe 'set encoding=' . e ! call feedkeys(":abc def\\\\"\", 'tx') ! call assert_equal('"abc ef', @:, e) ! call feedkeys(":abc def\\\\"\", 'tx') ! call assert_equal('"abcdef', @:) ! ! call feedkeys(":abc def ghi\\\\"\", 'tx') ! call assert_equal('"abc ghi', @:, e) ! ! call feedkeys(":abc def\\\\"\", 'tx') ! call assert_equal('"def', @:, e) ! endfor ! ! let &encoding = encoding_save ! endfunc ! ! func Test_cmdline_keymap_ctrl_hat() ! if !has('keymap') ! return ! endif ! set keymap=esperanto ! call feedkeys(":\"Jxauxdo \Jxauxdo \Jxauxdo\", 'tx') ! call assert_equal('"Jxauxdo Ĵaŭdo Jxauxdo', @:) ! set keymap= endfunc func Test_illegal_address1() *************** *** 741,760 **** " Test overstrike in the middle of the command line. call feedkeys(":\"01234\\\ab\\cd\", 'xt') ! call assert_equal('"0ab1cd4', @:) " Test overstrike going beyond end of command line. call feedkeys(":\"01234\\\ab\\cdefgh\", 'xt') ! call assert_equal('"0ab1cdefgh', @:) " Test toggling insert/overstrike a few times. call feedkeys(":\"01234\\ab\\cd\\ef\", 'xt') ! call assert_equal('"ab0cd3ef4', @:) endfor " Test overstrike with multi-byte characters. call feedkeys(":\"テキストエディタ\\\ab\\cd\", 'xt') ! call assert_equal('"テabキcdエディタ', @:) let &encoding = encoding_save endfunc --- 760,779 ---- " Test overstrike in the middle of the command line. call feedkeys(":\"01234\\\ab\\cd\", 'xt') ! call assert_equal('"0ab1cd4', @:, e) " Test overstrike going beyond end of command line. call feedkeys(":\"01234\\\ab\\cdefgh\", 'xt') ! call assert_equal('"0ab1cdefgh', @:, e) " Test toggling insert/overstrike a few times. call feedkeys(":\"01234\\ab\\cd\\ef\", 'xt') ! call assert_equal('"ab0cd3ef4', @:, e) endfor " Test overstrike with multi-byte characters. call feedkeys(":\"テキストエディタ\\\ab\\cd\", 'xt') ! call assert_equal('"テabキcdエディタ', @:, e) let &encoding = encoding_save endfunc *** ../vim-8.2.0022/src/testdir/test_ex_mode.vim 2019-12-18 22:25:34.498460528 +0100 --- src/testdir/test_ex_mode.vim 2019-12-18 22:22:37.487198788 +0100 *************** *** 0 **** --- 1,54 ---- + " Test editing line in Ex mode (see :help Q and :help gQ). + + " Helper function to test editing line in Q Ex mode + func Ex_Q(cmd) + " Is there a simpler way to test editing Ex line? + call feedkeys("Q" + \ .. "let s:test_ex =<< END\" + \ .. a:cmd .. "\" + \ .. "END\" + \ .. "visual\", 'tx') + return s:test_ex[0] + endfunc + + " Helper function to test editing line in gQ Ex mode + func Ex_gQ(cmd) + call feedkeys("gQ" .. a:cmd .. "\\"\", 'tx') + let ret = @:[1:] " Remove leading quote. + call feedkeys("visual\", 'tx') + return ret + endfunc + + " Helper function to test editing line with both Q and gQ Ex mode. + func Ex(cmd) + return [Ex_Q(a:cmd), Ex_gQ(a:cmd)] + endfunc + + " Test editing line in Ex mode (both Q and gQ) + func Test_ex_mode() + let encoding_save = &encoding + set sw=2 + + for e in ['utf8', 'latin1'] + exe 'set encoding=' . e + + call assert_equal(['bar', 'bar'], Ex("foo bar\bar"), e) + call assert_equal(["1\2", "1\2"], Ex("1\\2"), e) + call assert_equal(["1\2\3", '213'], Ex("1\2\3"), e) + call assert_equal(['0123', '2013'], Ex("01\2\3"), e) + call assert_equal(['0123', '0213'], Ex("01\2\3"), e) + call assert_equal(['01234', '0342'], Ex("012\\\3\4"), e) + call assert_equal(["foo bar\", 'foo '], Ex("foo bar\"), e) + call assert_equal(['foo', 'foo'], Ex("fooba\\"), e) + call assert_equal(["foo\tbar", 'foobar'], Ex("foo\bar"), e) + call assert_equal(["abbrev\t", 'abbreviate'], Ex("abbrev\"), e) + call assert_equal([' 1', "1\\"], Ex("1\\"), e) + call assert_equal([' 1', "1\\"], Ex("1\\\"), e) + call assert_equal([' foo', ' foo'], Ex(" foo\"), e) + call assert_equal(['foo', ' foo0'], Ex(" foo0\"), e) + call assert_equal(['foo', ' foo^'], Ex(" foo^\"), e) + endfor + + set sw& + let &encoding = encoding_save + endfunc *** ../vim-8.2.0022/src/version.c 2019-12-18 21:33:19.276859673 +0100 --- src/version.c 2019-12-18 22:23:49.046895311 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 23, /**/ -- FATHER: Make sure the Prince doesn't leave this room until I come and get him. FIRST GUARD: Not ... to leave the room ... even if you come and get him. FATHER: No. Until I come and get him. SECOND GUARD: Hic. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@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 ///