Mercurial > vim
diff src/userfunc.c @ 17646:e5397617d6ca v8.1.1820
patch 8.1.1820: using expr->FuncRef() does not work
commit https://github.com/vim/vim/commit/761fdf01c6e307c448cec2684f8b315ba6d1f454
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 5 23:10:16 2019 +0200
patch 8.1.1820: using expr->FuncRef() does not work
Problem: Using expr->FuncRef() does not work.
Solution: Make FuncRef work as a method.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 05 Aug 2019 23:15:05 +0200 |
parents | 9ffec4eb8d33 |
children | 121bdff812b4 |
line wrap: on
line diff
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -1498,6 +1498,7 @@ call_func( typval_T argv[MAX_FUNC_ARGS + 1]; // used when "partial" or // "funcexe->basetv" is not NULL int argv_clear = 0; + int argv_base = 0; partial_T *partial = funcexe->partial; // Make a copy of the name, if it comes from a funcref variable it could @@ -1590,9 +1591,9 @@ call_func( mch_memmove(&argv[1], argvars, sizeof(typval_T) * argcount); argv[0] = *funcexe->basetv; argcount++; + argvars = argv; + argv_base = 1; } - else - memcpy(argv, argvars, sizeof(typval_T) * argcount); if (fp->uf_flags & FC_RANGE && funcexe->doesrange != NULL) *funcexe->doesrange = TRUE; @@ -1621,7 +1622,7 @@ call_func( did_save_redo = TRUE; } ++fp->uf_calls; - call_user_func(fp, argcount, argv, rettv, + call_user_func(fp, argcount, argvars, rettv, funcexe->firstline, funcexe->lastline, (fp->uf_flags & FC_DICT) ? selfdict : NULL); if (--fp->uf_calls <= 0 && fp->uf_refcount <= 0) @@ -1698,8 +1699,10 @@ call_func( } } + // clear the copies made from the partial while (argv_clear > 0) - clear_tv(&argv[--argv_clear]); + clear_tv(&argv[--argv_clear + argv_base]); + vim_free(tofree); vim_free(name);