diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-08-08 15:10:27 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-08-08 15:10:27 +0200 |
commit | 2dd0a2c39a3b3fbffc94d0676e472c78d02ebdbd (patch) | |
tree | 3ed7fc3e3c3992ff3cb8d2fade3de7c2213605ff | |
parent | b7f4fa517793b0fe1a4895781b4cba451d60d7c2 (diff) | |
download | vim-git-2dd0a2c39a3b3fbffc94d0676e472c78d02ebdbd.tar.gz |
patch 8.2.1394: Vim9: compiling a function interferes with command modifiersv8.2.1394
Problem: Vim9: compiling a function interferes with command modifiers.
Solution: Save and restore command modifiers. (closes #6658)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 25 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 5 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 14 |
4 files changed, 35 insertions, 11 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 3cc1e112b..d39584154 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1351,5 +1351,30 @@ def Test_partial_call() assert_equal({'title': 'test'}, getqflist({'title': 1})) enddef +def Test_cmd_modifier() + tab echo '0' + call CheckDefFailure(['5tab echo 3'], 'E16:') +enddef + +def Test_restore_modifiers() + # check that when compiling a :def function command modifiers are not messed + # up. + let lines =<< trim END + vim9script + set eventignore= + autocmd QuickFixCmdPost * copen + def AutocmdsDisabled() + eval 0 + enddef + func Func() + noautocmd call s:AutocmdsDisabled() + let g:ei_after = &eventignore + endfunc + Func() + END + CheckScriptSuccess(lines) + assert_equal('', g:ei_after) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 3f1997f6f..10706b1d9 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -751,11 +751,6 @@ func Test_block_failure() call CheckDefFailure(['{', 'echo 1'], 'E1026:') endfunc -def Test_cmd_modifier() - tab echo '0' - call CheckDefFailure(['5tab echo 3'], 'E16:') -enddef - func g:NoSuchFunc() echo 'none' endfunc diff --git a/src/version.c b/src/version.c index 2febed675..17ed09b0f 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1394, +/**/ 1393, /**/ 1392, diff --git a/src/vim9compile.c b/src/vim9compile.c index 25da7f562..04681fee7 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2668,7 +2668,7 @@ next_line_from_context(cctx_T *cctx, int skip_comment) cctx->ctx_line_start = line; SOURCING_LNUM = cctx->ctx_lnum + 1; } while (line == NULL || *skipwhite(line) == NUL - || (skip_comment && vim9_comment_start(skipwhite(line)))); + || (skip_comment && vim9_comment_start(skipwhite(line)))); return line; } @@ -7194,10 +7194,11 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx) */ for (;;) { - exarg_T ea; - int starts_with_colon = FALSE; - char_u *cmd; - int save_msg_scroll = msg_scroll; + exarg_T ea; + cmdmod_T save_cmdmod; + int starts_with_colon = FALSE; + char_u *cmd; + int save_msg_scroll = msg_scroll; // Bail out on the first error to avoid a flood of errors and report // the right line number when inside try/catch. @@ -7278,6 +7279,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx) /* * COMMAND MODIFIERS */ + save_cmdmod = cmdmod; if (parse_command_modifiers(&ea, &errormsg, FALSE) == FAIL) { if (errormsg != NULL) @@ -7288,7 +7290,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx) } // TODO: use modifiers in the command undo_cmdmod(&ea, save_msg_scroll); - CLEAR_FIELD(cmdmod); + cmdmod = save_cmdmod; // Skip ":call" to get to the function name. if (checkforcmd(&ea.cmd, "call", 3)) |