diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-06-30 16:03:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-30 16:03:58 +0200 |
commit | 10a533e9d41ad8917c17e96cf696fcea4b07374f (patch) | |
tree | 69bcc294d1a956856578e9dfb6d87271b6057729 /src/nvim/lua/vim.lua | |
parent | 3b504e7c8d20bb41ef6b6f95e46527766438046a (diff) | |
parent | 99f24dfbed84cea24fc1d8bb80ab10a2dd3eca0b (diff) | |
download | rneovim-10a533e9d41ad8917c17e96cf696fcea4b07374f.tar.gz rneovim-10a533e9d41ad8917c17e96cf696fcea4b07374f.tar.bz2 rneovim-10a533e9d41ad8917c17e96cf696fcea4b07374f.zip |
Merge pull request #10316 from bfredl/cb_safety
luv callbacks: throw error on deferred methods instead of crashing
Diffstat (limited to 'src/nvim/lua/vim.lua')
-rw-r--r-- | src/nvim/lua/vim.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index 848bccaae6..46c96b455f 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -172,11 +172,22 @@ local function __index(t, key) end end +--- Defers the wrapped callback until when the nvim API is safe to call. +--- +--- See |vim-loop-callbacks| +local function schedule_wrap(cb) + return (function (...) + local args = {...} + vim.schedule(function() cb(unpack(args)) end) + end) +end + local module = { _update_package_paths = _update_package_paths, _os_proc_children = _os_proc_children, _os_proc_info = _os_proc_info, _system = _system, + schedule_wrap = schedule_wrap, } setmetatable(module, { |