To: vim_dev@googlegroups.com Subject: Patch 8.2.4628 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4628 Problem: Not enough testing for 2/3 letter substitute commands. Solution: Add more tests. (Yegappan Lakshmanan, closes #10019) Files: src/testdir/test_cmdline.vim, src/testdir/test_substitute.vim *** ../vim-8.2.4627/src/testdir/test_cmdline.vim 2022-03-24 11:22:07.219294092 +0000 --- src/testdir/test_cmdline.vim 2022-03-25 21:13:43.455931595 +0000 *************** *** 3284,3287 **** --- 3284,3300 ---- set wildmenu& endfunc + " Test for expanding 2-letter and 3-letter :substitute command arguments. + " These commands don't accept an argument. + func Test_cmdline_complete_substitute_short() + for cmd in ['sc', 'sce', 'scg', 'sci', 'scI', 'scn', 'scp', 'scl', + \ 'sgc', 'sge', 'sg', 'sgi', 'sgI', 'sgn', 'sgp', 'sgl', 'sgr', + \ 'sic', 'sie', 'si', 'siI', 'sin', 'sip', 'sir', + \ 'sIc', 'sIe', 'sIg', 'sIi', 'sI', 'sIn', 'sIp', 'sIl', 'sIr', + \ 'src', 'srg', 'sri', 'srI', 'srn', 'srp', 'srl', 'sr'] + call feedkeys(':' .. cmd .. " \\\"\", 'tx') + call assert_equal('"' .. cmd .. " \", @:) + endfor + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4627/src/testdir/test_substitute.vim 2022-03-05 21:13:22.747737446 +0000 --- src/testdir/test_substitute.vim 2022-03-25 21:13:43.459931594 +0000 *************** *** 1,4 **** ! " Tests for multi-line regexps with ":s". source shared.vim source check.vim --- 1,4 ---- ! " Tests for the substitute (:s) command source shared.vim source check.vim *************** *** 1000,1004 **** --- 1000,1286 ---- set nocompatible endfunc + " Test for the 2-letter and 3-letter :substitute commands + func Test_substitute_short_cmd() + new + call setline(1, ['one', 'one one one']) + s/one/two + call cursor(2, 1) + + " :sc + call feedkeys(":sc\y", 'xt') + call assert_equal('two one one', getline(2)) + + " :scg + call setline(2, 'one one one') + call feedkeys(":scg\nyq", 'xt') + call assert_equal('one two one', getline(2)) + + " :sci + call setline(2, 'ONE One onE') + call feedkeys(":sci\y", 'xt') + call assert_equal('two One onE', getline(2)) + + " :scI + set ignorecase + call setline(2, 'ONE One one') + call feedkeys(":scI\y", 'xt') + call assert_equal('ONE One two', getline(2)) + set ignorecase& + + " :scn + call setline(2, 'one one one') + let t = execute('scn')->split("\n") + call assert_equal(['1 match on 1 line'], t) + call assert_equal('one one one', getline(2)) + + " :scp + call setline(2, "\tone one one") + redir => output + call feedkeys(":scp\y", 'xt') + redir END + call assert_equal(' two one one', output->split("\n")[-1]) + call assert_equal("\ttwo one one", getline(2)) + + " :scl + call setline(2, "\tone one one") + redir => output + call feedkeys(":scl\y", 'xt') + redir END + call assert_equal("^Itwo one one$", output->split("\n")[-1]) + call assert_equal("\ttwo one one", getline(2)) + + " :sgc + call setline(2, 'one one one one one') + call feedkeys(":sgc\nyyq", 'xt') + call assert_equal('one two two one one', getline(2)) + + " :sg + call setline(2, 'one one one') + sg + call assert_equal('two two two', getline(2)) + + " :sgi + call setline(2, 'ONE One onE') + sgi + call assert_equal('two two two', getline(2)) + + " :sgI + set ignorecase + call setline(2, 'ONE One one') + sgI + call assert_equal('ONE One two', getline(2)) + set ignorecase& + + " :sgn + call setline(2, 'one one one') + let t = execute('sgn')->split("\n") + call assert_equal(['3 matches on 1 line'], t) + call assert_equal('one one one', getline(2)) + + " :sgp + call setline(2, "\tone one one") + redir => output + sgp + redir END + call assert_equal(' two two two', output->split("\n")[-1]) + call assert_equal("\ttwo two two", getline(2)) + + " :sgl + call setline(2, "\tone one one") + redir => output + sgl + redir END + call assert_equal("^Itwo two two$", output->split("\n")[-1]) + call assert_equal("\ttwo two two", getline(2)) + + " :sgr + call setline(2, "one one one") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + sgr + call assert_equal('xyz xyz xyz', getline(2)) + + " :sic + call cursor(1, 1) + s/one/two/e + call setline(2, "ONE One one") + call cursor(2, 1) + call feedkeys(":sic\y", 'xt') + call assert_equal('two One one', getline(2)) + + " :si + call setline(2, "ONE One one") + si + call assert_equal('two One one', getline(2)) + + " :siI + call setline(2, "ONE One one") + siI + call assert_equal('ONE One two', getline(2)) + + " :sin + call setline(2, 'ONE One onE') + let t = execute('sin')->split("\n") + call assert_equal(['1 match on 1 line'], t) + call assert_equal('ONE One onE', getline(2)) + + " :sip + call setline(2, "\tONE One onE") + redir => output + sip + redir END + call assert_equal(' two One onE', output->split("\n")[-1]) + call assert_equal("\ttwo One onE", getline(2)) + + " :sir + call setline(2, "ONE One onE") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + sir + call assert_equal('xyz One onE', getline(2)) + + " :sIc + call cursor(1, 1) + s/one/two/e + call setline(2, "ONE One one") + call cursor(2, 1) + call feedkeys(":sIc\y", 'xt') + call assert_equal('ONE One two', getline(2)) + + " :sIg + call setline(2, "ONE one onE one") + sIg + call assert_equal('ONE two onE two', getline(2)) + + " :sIi + call setline(2, "ONE One one") + sIi + call assert_equal('two One one', getline(2)) + + " :sI + call setline(2, "ONE One one") + sI + call assert_equal('ONE One two', getline(2)) + + " :sIn + call setline(2, 'ONE One one') + let t = execute('sIn')->split("\n") + call assert_equal(['1 match on 1 line'], t) + call assert_equal('ONE One one', getline(2)) + + " :sIp + call setline(2, "\tONE One one") + redir => output + sIp + redir END + call assert_equal(' ONE One two', output->split("\n")[-1]) + call assert_equal("\tONE One two", getline(2)) + + " :sIl + call setline(2, "\tONE onE one") + redir => output + sIl + redir END + call assert_equal("^IONE onE two$", output->split("\n")[-1]) + call assert_equal("\tONE onE two", getline(2)) + + " :sIr + call setline(2, "ONE one onE") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + sIr + call assert_equal('ONE xyz onE', getline(2)) + + " :src + call setline(2, "ONE one one") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + call feedkeys(":src\y", 'xt') + call assert_equal('ONE xyz one', getline(2)) + + " :srg + call setline(2, "one one one") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + srg + call assert_equal('xyz xyz xyz', getline(2)) + + " :sri + call setline(2, "ONE one onE") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + sri + call assert_equal('xyz one onE', getline(2)) + + " :srI + call setline(2, "ONE one onE") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + srI + call assert_equal('ONE xyz onE', getline(2)) + + " :srn + call setline(2, "ONE one onE") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + let t = execute('srn')->split("\n") + call assert_equal(['1 match on 1 line'], t) + call assert_equal('ONE one onE', getline(2)) + + " :srp + call setline(2, "\tONE one onE") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + redir => output + srp + redir END + call assert_equal(' ONE xyz onE', output->split("\n")[-1]) + call assert_equal("\tONE xyz onE", getline(2)) + + " :srl + call setline(2, "\tONE one onE") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + redir => output + srl + redir END + call assert_equal("^IONE xyz onE$", output->split("\n")[-1]) + call assert_equal("\tONE xyz onE", getline(2)) + + " :sr + call setline(2, "ONE one onE") + call cursor(2, 1) + s/abc/xyz/e + let @/ = 'one' + sr + call assert_equal('ONE xyz onE', getline(2)) + + " :sce + s/abc/xyz/e + call assert_fails("sc", 'E486:') + sce + " :sge + call assert_fails("sg", 'E486:') + sge + " :sie + call assert_fails("si", 'E486:') + sie + " :sIe + call assert_fails("sI", 'E486:') + sIe + + bw! + endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4627/src/version.c 2022-03-25 19:50:53.877135393 +0000 --- src/version.c 2022-03-25 21:18:44.391548991 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4628, /**/ -- WOMAN: I didn't know we had a king. I thought we were an autonomous collective. DENNIS: You're fooling yourself. We're living in a dictatorship. A self-perpetuating autocracy in which the working classes-- WOMAN: Oh there you go, bringing class into it again. DENNIS: That's what it's all about if only people would-- The Quest for the Holy Grail (Monty Python) /// 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 ///