Patch 8.0.0176 Problem: Using :change in between :function and :endfunction fails. Solution: Recognize :change inside a function. (ichizok, closes #1374) Files: src/userfunc.c, src/testdir/test_viml.vim
*** ../vim-8.0.0175/src/userfunc.c 2016-11-10 20:01:41.201582868 +0100 --- src/userfunc.c 2017-01-12 22:15:55.659667539 +0100 *************** *** 2085,2093 **** } } ! /* Check for ":append" or ":insert". */ p = skip_range(p, NULL); if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p')) || (p[0] == 'i' && (!ASCII_ISALPHA(p[1]) || (p[1] == 'n' && (!ASCII_ISALPHA(p[2]) || (p[2] == 's')))))) --- 2085,2098 ---- } } ! /* Check for ":append", ":change", ":insert". */ p = skip_range(p, NULL); if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p')) + || (p[0] == 'c' + && (!ASCII_ISALPHA(p[1]) || (p[1] == 'h' + && (!ASCII_ISALPHA(p[2]) || (p[2] == 'a' + && (STRNCMP(&p[3], "nge", 3) != 0 + || !ASCII_ISALPHA(p[6]))))))) || (p[0] == 'i' && (!ASCII_ISALPHA(p[1]) || (p[1] == 'n' && (!ASCII_ISALPHA(p[2]) || (p[2] == 's')))))) *** ../vim-8.0.0175/src/testdir/test_viml.vim 2016-07-19 17:11:58.000000000 +0200 --- src/testdir/test_viml.vim 2017-01-12 22:15:18.627955280 +0100 *************** *** 1239,1244 **** --- 1239,1315 ---- endfunc "------------------------------------------------------------------------------- + " Test 95: lines of :append, :change, :insert {{{1 + "------------------------------------------------------------------------------- + + function! DefineFunction(name, body) + let func = join(['function! ' . a:name . '()'] + a:body + ['endfunction'], "\n") + exec func + endfunction + + func Test_script_lines() + " :append + try + call DefineFunction('T_Append', [ + \ 'append', + \ 'py <<EOS', + \ '.', + \ ]) + catch + call assert_false(1, "Can't define function") + endtry + try + call DefineFunction('T_Append', [ + \ 'append', + \ 'abc', + \ ]) + call assert_false(1, "Shouldn't be able to define function") + catch + call assert_exception('Vim(function):E126: Missing :endfunction') + endtry + + " :change + try + call DefineFunction('T_Change', [ + \ 'change', + \ 'py <<EOS', + \ '.', + \ ]) + catch + call assert_false(1, "Can't define function") + endtry + try + call DefineFunction('T_Change', [ + \ 'change', + \ 'abc', + \ ]) + call assert_false(1, "Shouldn't be able to define function") + catch + call assert_exception('Vim(function):E126: Missing :endfunction') + endtry + + " :insert + try + call DefineFunction('T_Insert', [ + \ 'insert', + \ 'py <<EOS', + \ '.', + \ ]) + catch + call assert_false(1, "Can't define function") + endtry + try + call DefineFunction('T_Insert', [ + \ 'insert', + \ 'abc', + \ ]) + call assert_false(1, "Shouldn't be able to define function") + catch + call assert_exception('Vim(function):E126: Missing :endfunction') + endtry + endfunc + + "------------------------------------------------------------------------------- " Modelines {{{1 " vim: ts=8 sw=4 tw=80 fdm=marker " vim: fdt=substitute(substitute(foldtext(),\ '\\%(^+--\\)\\@<=\\(\\s*\\)\\(.\\{-}\\)\:\ \\%(\"\ \\)\\=\\(Test\ \\d*\\)\:\\s*',\ '\\3\ (\\2)\:\ \\1',\ \"\"),\ '\\(Test\\s*\\)\\(\\d\\)\\D\\@=',\ '\\1\ \\2',\ "") *** ../vim-8.0.0175/src/version.c 2017-01-12 21:44:45.146171805 +0100 --- src/version.c 2017-01-12 22:17:49.762780784 +0100 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 176, /**/ -- hundred-and-one symptoms of being an internet addict: 259. When you enter your name in the AltaVista search engine, the top ten matches do indeed refer to you. /// Bram Moolenaar -- b...@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 /// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.