aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-27 21:49:57 +0800
committerGitHub <noreply@github.com>2025-02-27 13:49:57 +0000
commit89d6d6f25cf22175e8c8eedef7181d8d618f9898 (patch)
tree43184d9926113f55248d56f77e8de2dc325679fd /test
parentf25dd7a8d54844effb44dad60e8154bc8172a67a (diff)
downloadrneovim-89d6d6f25cf22175e8c8eedef7181d8d618f9898.tar.gz
rneovim-89d6d6f25cf22175e8c8eedef7181d8d618f9898.tar.bz2
rneovim-89d6d6f25cf22175e8c8eedef7181d8d618f9898.zip
fix(lua): wrong script context for option set by func from nvim_exec2 (#32659)
Problem: Wrong script context for option set by function defined by nvim_exec2 in a Lua script. Solution: Call nlua_set_sctx() after adding SOURCING_LNUM and always set sc_lnum for a Lua script. This is a bug discovered when testing #28486. Not sure if this actually happens in practice, but it's easy to fix and required for #28486.
Diffstat (limited to 'test')
-rw-r--r--test/functional/ex_cmds/verbose_spec.lua26
1 files changed, 24 insertions, 2 deletions
diff --git a/test/functional/ex_cmds/verbose_spec.lua b/test/functional/ex_cmds/verbose_spec.lua
index 071e9690fa..0187baf4ac 100644
--- a/test/functional/ex_cmds/verbose_spec.lua
+++ b/test/functional/ex_cmds/verbose_spec.lua
@@ -23,7 +23,7 @@ local function last_set_lua_verbose_tests(cmd, v1)
write_file(
script_file,
- [[
+ [=[
vim.api.nvim_set_option_value('hlsearch', false, {})
vim.bo.expandtab = true
vim.opt.number = true
@@ -70,8 +70,17 @@ endfunction\
let &tw = s:return80()\
", {})
+local set_list = ([[
+ func SetList()
+%s
+ set list
+ endfunc
+ call SetList()
+]]):format(('\n'):rep(1234))
+vim.api.nvim_exec2(set_list, {})
+
vim.api.nvim_create_autocmd('User', { pattern = 'set_mouse', callback = cb })
-]]
+]=]
)
exec(cmd .. ' ' .. script_file)
exec('doautocmd User set_mouse')
@@ -259,6 +268,19 @@ TestHL2 xxx guibg=Green
result
)
end)
+
+ it('for option set by function in nvim_exec2', function()
+ local result = exec_capture(':verbose set list?')
+ eq(
+ string.format(
+ [[
+ list
+ Last set from %s]],
+ get_last_set_location(54)
+ ),
+ result
+ )
+ end)
end
describe('lua :verbose with -V1', function()