diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-02-16 10:52:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 10:52:38 +0100 |
commit | 9fe8d2c9df2decccd09828cb99ae7a19635c7dc3 (patch) | |
tree | 6fb9bb19a54ecfed25db127e65e4c134f6b6c77a | |
parent | 0852644bee77f13563d805233c35227b9a00798f (diff) | |
parent | d512be55a2ea54dd83914ff25f57c02d703f93b4 (diff) | |
download | rneovim-9fe8d2c9df2decccd09828cb99ae7a19635c7dc3.tar.gz rneovim-9fe8d2c9df2decccd09828cb99ae7a19635c7dc3.tar.bz2 rneovim-9fe8d2c9df2decccd09828cb99ae7a19635c7dc3.zip |
Merge pull request #16678 from lewis6991/runtime_file_err
fix(api): re-route nvim_get_runtime_file errors
-rw-r--r-- | src/nvim/api/vim.c | 8 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 9 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 565015cada..11bb1750e4 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -497,8 +497,12 @@ ArrayOf(String) nvim_get_runtime_file(String name, Boolean all, Error *err) int flags = DIP_DIRFILE | (all ? DIP_ALL : 0); - do_in_runtimepath((char_u *)(name.size ? name.data : ""), - flags, find_runtime_cb, &rv); + TRY_WRAP({ + try_start(); + do_in_runtimepath((char_u *)(name.size ? name.data : ""), + flags, find_runtime_cb, &rv); + try_end(err); + }); return rv; } diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 5a387f3deb..71cd055e08 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -23,6 +23,7 @@ local next_msg = helpers.next_msg local tmpname = helpers.tmpname local write_file = helpers.write_file local exec_lua = helpers.exec_lua +local exc_exec = helpers.exc_exec local pcall_err = helpers.pcall_err local format_string = helpers.format_string @@ -2240,6 +2241,14 @@ describe('API', function() eq({}, meths.get_runtime_file("foobarlang/", true)) end) + it('can handle bad patterns', function() + if helpers.pending_win32(pending) then return end + + eq("Vim:E220: Missing }.", pcall_err(meths.get_runtime_file, "{", false)) + + eq('Vim(echo):E5555: API call: Vim:E220: Missing }.', + exc_exec("echo nvim_get_runtime_file('{', v:false)")) + end) end) describe('nvim_get_all_options_info', function() |