aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/commands_spec.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-02-02 06:14:10 +0100
committerGitHub <noreply@github.com>2024-02-02 13:14:10 +0800
commit4a1ad676ce0bdaead122b092d2ff33b51679ffe9 (patch)
tree43b2f09fc1e396c1d3afdc269f03f2fd8a66515f /test/functional/lua/commands_spec.lua
parent1405e5c8c1f3b3ef59cab0ac2d0a28b9b88869cf (diff)
downloadrneovim-4a1ad676ce0bdaead122b092d2ff33b51679ffe9.tar.gz
rneovim-4a1ad676ce0bdaead122b092d2ff33b51679ffe9.tar.bz2
rneovim-4a1ad676ce0bdaead122b092d2ff33b51679ffe9.zip
feat(ex_cmds): no error on :lua with {range} and {code} (#27290)
Problem: Erroring when both {range} and {code} are supplied to :lua is inconvenient and may break mappings. Solution: Don't error, ignore {range} and execute {code} when both are supplied.
Diffstat (limited to 'test/functional/lua/commands_spec.lua')
-rw-r--r--test/functional/lua/commands_spec.lua11
1 files changed, 5 insertions, 6 deletions
diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua
index 3090cff7aa..b8d0638ce5 100644
--- a/test/functional/lua/commands_spec.lua
+++ b/test/functional/lua/commands_spec.lua
@@ -56,12 +56,7 @@ describe(':lua', function()
end)
it('throws catchable errors', function()
- for _, cmd in ipairs({ 'lua', '1lua chunk' }) do
- eq(
- 'Vim(lua):E475: Invalid argument: exactly one of {chunk} or {range} required',
- pcall_err(command, cmd)
- )
- end
+ eq('Vim(lua):E471: Argument required', pcall_err(command, 'lua'))
eq(
[[Vim(lua):E5107: Error loading lua [string ":lua"]:0: unexpected symbol near ')']],
pcall_err(command, 'lua ()')
@@ -230,6 +225,10 @@ describe(':lua', function()
[1] = { foreground = Screen.colors.Blue, bold = true },
},
}
+
+ -- ":{range}lua {code}" executes {code}, ignoring {range}
+ eq('', exec_capture('1lua gvar = 42'))
+ eq(42, fn.luaeval('gvar'))
end)
end)