Mercurial > vim
changeset 24073:c424821dc031 v8.2.2578
patch 8.2.2578: Lua cannot handle a passed in lambda
Commit: https://github.com/vim/vim/commit/86c3a2162c2e78b4f0b87b47779cc1452990ee1b
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 8 19:50:24 2021 +0100
patch 8.2.2578: Lua cannot handle a passed in lambda
Problem: Lua cannot handle a passed in lambda.
Solution: Handle VAR_PARTIAL. (Prabir Shrestha, closes https://github.com/vim/vim/issues/7937, closes https://github.com/vim/vim/issues/7936)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 08 Mar 2021 20:00:03 +0100 |
parents | 25305dfc4c92 |
children | f950af3477e2 |
files | src/if_lua.c src/testdir/test_lua.vim src/version.c |
diffstat | 3 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/if_lua.c +++ b/src/if_lua.c @@ -568,6 +568,11 @@ luaV_pushtypval(lua_State *L, typval_T * case VAR_FUNC: luaV_pushfuncref(L, tv->vval.v_string); break; + case VAR_PARTIAL: + // TODO: handle partial arguments + luaV_pushfuncref(L, partial_name(tv->vval.v_partial)); + break; + case VAR_BLOB: luaV_pushblob(L, tv->vval.v_blob); break;
--- a/src/testdir/test_lua.vim +++ b/src/testdir/test_lua.vim @@ -121,6 +121,15 @@ func Test_lua_eval() lua v = nil endfunc +" Test luaeval() with lambda +func Test_luaeval_with_lambda() + lua function hello_luaeval_lambda(a, cb) return a .. cb() end + call assert_equal('helloworld', + \ luaeval('hello_luaeval_lambda(_A[1], _A[2])', + \ ['hello', {->'world'}])) + lua hello_luaeval_lambda = nil +endfunc + " Test vim.window() func Test_lua_window() e Xfoo2