]> granicus.if.org Git - vim/commitdiff
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost v8.2.1293
authorBram Moolenaar <Bram@vim.org>
Sat, 25 Jul 2020 17:30:59 +0000 (19:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 25 Jul 2020 17:30:59 +0000 (19:30 +0200)
Problem:    Vim9: error when using vim9script in TextYankPost.
Solution:   Use EX_LOCKOK instead of the EX_CMDWIN flag for command that can
            be used when text is locked. (closes #6529)

src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c

index f7d195ea834c43b3f862cf23247607e9556ee775..ac76e8d5bce04769212f4ee559b73c8ace6ae258 100644 (file)
@@ -1708,6 +1708,10 @@ def Test_execute_cmd()
   assert_equal('execute-var-var', getline(1))
   bwipe!
 
+  let n = true
+  execute 'echomsg' (n ? '"true"' : '"no"')
+  assert_match('^true$', Screenline(&lines))
+
   call CheckDefFailure(['execute xxx'], 'E1001:')
   call CheckDefFailure(['execute "cmd"# comment'], 'E488:')
 enddef
@@ -2634,6 +2638,32 @@ def Test_vim9_copen()
   quit
 enddef
 
+" test using a vim9script that is auto-loaded from an autocmd
+def Test_vim9_autoload()
+  let lines =<< trim END
+     vim9script
+     def foo#test()
+         echomsg getreg('"')
+     enddef
+  END
+
+  mkdir('Xdir/autoload', 'p')
+  writefile(lines, 'Xdir/autoload/foo.vim')
+  let save_rtp = &rtp
+  exe 'set rtp^=' .. getcwd() .. '/Xdir'
+  augroup test
+    autocmd TextYankPost * call foo#test()
+  augroup END
+
+  normal Y
+
+  augroup test
+    autocmd!
+  augroup END
+  delete('Xdir', 'rf')
+  &rtp = save_rtp
+enddef
+
 " Keep this last, it messes up highlighting.
 def Test_substitute_cmd()
   new
index 3611fe6a4b88977ee3cdc1dc21bc960dabe6dccc..05f37526d4ed252edd1923e912aa76e2e833d293 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1293,
 /**/
     1292,
 /**/
index 53bfb6c48e034eeaef7624e158159672f98db49f..746c9aa1a2d5b79ab47f174d2c4624c4c2e619de 100644 (file)
@@ -3755,7 +3755,9 @@ compile_subscript(
            }
        }
 
-       if (*p == '(')
+       // Do not skip over white space to find the "(", "exeucte 'x' ()" is
+       // not a function call.
+       if (**arg == '(')
        {
            garray_T    *stack = &cctx->ctx_type_stack;
            type_T      *type;