From e2aca58bcc4f0aff8da9683194e4dc857a56118f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Feb 2025 07:40:21 +0800 Subject: 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(). --- test/functional/ex_cmds/source_spec.lua | 31 ++++-- test/functional/ex_cmds/verbose_spec.lua | 163 +++++++++++++++++++------------ test/functional/lua/runtime_spec.lua | 22 ++++- 3 files changed, 145 insertions(+), 71 deletions(-) (limited to 'test') diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua index 0a6f44fab4..40225784f5 100644 --- a/test/functional/ex_cmds/source_spec.lua +++ b/test/functional/ex_cmds/source_spec.lua @@ -6,6 +6,7 @@ local insert = n.insert local eq = t.eq local clear = n.clear local api = n.api +local fn = n.fn local feed = n.feed local feed_command = n.feed_command local write_file = t.write_file @@ -169,8 +170,9 @@ describe(':source', function() eq('4', exec_capture('echo luaeval("y")')) end) - it('can source lua files', function() - local test_file = 'test.lua' + --- @param verbose boolean + local function test_source_lua_file(verbose) + local test_file = 'Xtest.lua' write_file( test_file, [[ @@ -178,17 +180,32 @@ describe(':source', function() vim.g.sfile_value = vim.fn.expand('') vim.g.stack_value = vim.fn.expand('') vim.g.script_value = vim.fn.expand('