aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-26 07:40:21 +0800
committerGitHub <noreply@github.com>2025-02-25 23:40:21 +0000
commite2aca58bcc4f0aff8da9683194e4dc857a56118f (patch)
treed077b324c29de6d53ca42f9496efb9451fc40b05 /test/functional/lua
parentaf0a2157ad2958b6c1e3c374ac247726c252c219 (diff)
downloadrneovim-e2aca58bcc4f0aff8da9683194e4dc857a56118f.tar.gz
rneovim-e2aca58bcc4f0aff8da9683194e4dc857a56118f.tar.bz2
rneovim-e2aca58bcc4f0aff8da9683194e4dc857a56118f.zip
fix(lua): don't override script ID from :source (#32626)
Problem: When setting an option, mapping etc. from Lua without -V1, the script ID is set to SID_LUA even if there already is a script ID assigned by :source. Solution: Don't set script ID to SID_LUA if it is already a Lua script. Also add _editor.lua to ignorelist to make script context more useful when using vim.cmd().
Diffstat (limited to 'test/functional/lua')
-rw-r--r--test/functional/lua/runtime_spec.lua22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/functional/lua/runtime_spec.lua b/test/functional/lua/runtime_spec.lua
index 6705dff847..b903db14b4 100644
--- a/test/functional/lua/runtime_spec.lua
+++ b/test/functional/lua/runtime_spec.lua
@@ -5,6 +5,7 @@ local clear = n.clear
local eq = t.eq
local eval = n.eval
local exec = n.exec
+local api = n.api
local fn = n.fn
local mkdir_p = n.mkdir_p
local rmdir = n.rmdir
@@ -15,9 +16,10 @@ describe('runtime:', function()
local sep = n.get_pathsep()
local init = 'dummy_init.lua'
+ -- All test cases below use the same Nvim instance.
setup(function()
io.open(init, 'w'):close() -- touch init file
- clear { args = { '-u', init } }
+ clear({ args = { '-u', init } })
exec('set rtp+=' .. plug_dir)
exec([[
set shell=doesnotexist
@@ -39,6 +41,8 @@ describe('runtime:', function()
after_each(function()
rmdir(plug_dir)
exec('bwipe!')
+ exec('set rtp& pp&')
+ exec('set rtp+=' .. plug_dir)
end)
describe('colors', function()
@@ -404,6 +408,22 @@ describe('runtime:', function()
end)
end)
+ it('lua file loaded by :runtime has proper script ID #32598', function()
+ local test_file = 'Xtest_runtime_cmd.lua'
+ write_file(
+ table.concat({ plug_dir, test_file }, sep),
+ [[
+ vim.g.script_id = tonumber(vim.fn.expand('<SID>'):match('<SNR>(%d+)_'))
+ vim.o.mouse = 'nv'
+ ]]
+ )
+ exec('runtime ' .. test_file)
+ local expected_sid = fn.getscriptinfo({ name = test_file })[1].sid
+ local sid = api.nvim_get_var('script_id')
+ eq(expected_sid, sid)
+ eq(sid, api.nvim_get_option_info2('mouse', {}).last_set_sid)
+ end)
+
it('cpp ftplugin loads c ftplugin #29053', function()
eq('', eval('&commentstring'))
eq('', eval('&omnifunc'))