diff options
-rw-r--r-- | src/nvim/api/private/helpers.c | 6 | ||||
-rw-r--r-- | test/functional/api/tabpage_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/api/window_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/autocmd/autocmd_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/eval/api_functions_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/lua/api_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/lua/commands_spec.lua | 2 |
7 files changed, 15 insertions, 11 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index cdd1f42ae1..36331eee6e 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -631,7 +631,7 @@ buf_T *find_buffer_by_handle(Buffer buffer, Error *err) buf_T *rv = handle_get_buffer(buffer); if (!rv) { - api_set_error(err, kErrorTypeValidation, "Invalid buffer id"); + api_set_error(err, kErrorTypeValidation, "Invalid buffer id: %d", buffer); } return rv; @@ -646,7 +646,7 @@ win_T *find_window_by_handle(Window window, Error *err) win_T *rv = handle_get_window(window); if (!rv) { - api_set_error(err, kErrorTypeValidation, "Invalid window id"); + api_set_error(err, kErrorTypeValidation, "Invalid window id: %d", window); } return rv; @@ -661,7 +661,7 @@ tabpage_T *find_tab_by_handle(Tabpage tabpage, Error *err) tabpage_T *rv = handle_get_tabpage(tabpage); if (!rv) { - api_set_error(err, kErrorTypeValidation, "Invalid tabpage id"); + api_set_error(err, kErrorTypeValidation, "Invalid tabpage id: %d", tabpage); } return rv; diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua index ed7ce72597..20b3163d95 100644 --- a/test/functional/api/tabpage_spec.lua +++ b/test/functional/api/tabpage_spec.lua @@ -24,6 +24,10 @@ describe('api/tabpage', function() nvim('set_current_win', win3) eq(win3, tabpage('get_win', tab2)) end) + + it('validates args', function() + eq('Invalid tabpage id: 23', pcall_err(tabpage, 'list_wins', 23)) + end) end) describe('{get,set,del}_var', function() diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 17e0d3235c..8c7c3208c0 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -55,8 +55,8 @@ describe('API/win', function() end) it('validates args', function() - eq('Invalid buffer id', pcall_err(window, 'set_buf', nvim('get_current_win'), 23)) - eq('Invalid window id', pcall_err(window, 'set_buf', 23, nvim('get_current_buf'))) + eq('Invalid buffer id: 23', pcall_err(window, 'set_buf', nvim('get_current_win'), 23)) + eq('Invalid window id: 23', pcall_err(window, 'set_buf', 23, nvim('get_current_buf'))) end) end) @@ -73,7 +73,7 @@ describe('API/win', function() it('does not leak memory when using invalid window ID with invalid pos', function() - eq('Invalid window id', pcall_err(meths.win_set_cursor, 1, {"b\na"})) + eq('Invalid window id: 1', pcall_err(meths.win_set_cursor, 1, {"b\na"})) end) it('updates the screen, and also when the window is unfocused', function() diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua index 805db9dd78..43534c9e7e 100644 --- a/test/functional/autocmd/autocmd_spec.lua +++ b/test/functional/autocmd/autocmd_spec.lua @@ -219,7 +219,7 @@ describe('autocmd', function() eq(7, eval('g:test')) -- API calls are blocked when aucmd_win is not in scope - eq('Vim(call):E5555: API call: Invalid window id', + eq('Vim(call):E5555: API call: Invalid window id: 1001', pcall_err(command, "call nvim_set_current_win(g:winid)")) -- second time aucmd_win is needed, a different code path is invoked @@ -257,7 +257,7 @@ describe('autocmd', function() eq(0, eval('g:had_value')) eq(7, eval('g:test')) - eq('Vim(call):E5555: API call: Invalid window id', + eq('Vim(call):E5555: API call: Invalid window id: 1001', pcall_err(command, "call nvim_set_current_win(g:winid)")) end) diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua index f527aff33f..ccd97fc8c7 100644 --- a/test/functional/eval/api_functions_spec.lua +++ b/test/functional/eval/api_functions_spec.lua @@ -44,7 +44,7 @@ describe('eval-API', function() eq('Vim(call):E5555: API call: Wrong type for argument 1, expecting Buffer', err) err = exc_exec('call nvim_buf_line_count(17)') - eq('Vim(call):E5555: API call: Invalid buffer id', err) + eq('Vim(call):E5555: API call: Invalid buffer id: 17', err) end) diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua index 23167d3ed9..896554f7a3 100644 --- a/test/functional/lua/api_spec.lua +++ b/test/functional/lua/api_spec.lua @@ -39,7 +39,7 @@ describe('luaeval(vim.api.…)', function() eq({false, 'Argument "pos" must be a [row, col] array'}, funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, 0, {1, 2, 3})}')) -- Used to produce a memory leak due to a bug in nvim_win_set_cursor - eq({false, 'Invalid window id'}, + eq({false, 'Invalid window id: -1'}, funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, -1, {1, 2, 3})}')) end) diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua index 96eaa7991b..cbc3aee557 100644 --- a/test/functional/lua/commands_spec.lua +++ b/test/functional/lua/commands_spec.lua @@ -47,7 +47,7 @@ describe(':lua command', function() pcall_err(command, 'lua ()')) eq([[Vim(lua):E5108: Error executing lua [string ":lua"]:1: TEST]], exc_exec('lua error("TEST")')) - eq([[Vim(lua):E5108: Error executing lua [string ":lua"]:1: Invalid buffer id]], + eq([[Vim(lua):E5108: Error executing lua [string ":lua"]:1: Invalid buffer id: -10]], exc_exec('lua vim.api.nvim_buf_set_lines(-10, 1, 1, false, {"TEST"})')) eq({''}, curbufmeths.get_lines(0, 100, false)) end) |