aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-16 14:54:31 +0800
committerGitHub <noreply@github.com>2022-07-16 14:54:31 +0800
commit711a6a915767a97300aba76fb9d79b9784bc76ce (patch)
treef994e4691c3f1f616bf29bef7b4745abcf58c81f
parentfa29bc94b5f9e3cfe5b8c9a104f301c975e711d4 (diff)
downloadrneovim-711a6a915767a97300aba76fb9d79b9784bc76ce.tar.gz
rneovim-711a6a915767a97300aba76fb9d79b9784bc76ce.tar.bz2
rneovim-711a6a915767a97300aba76fb9d79b9784bc76ce.zip
fix(ex_cmds): correct flags for :const (#19387)
-rw-r--r--src/nvim/ex_cmds.lua2
-rw-r--r--test/functional/vimscript/let_spec.lua17
2 files changed, 18 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua
index 2bf867c32c..8c8cde8be3 100644
--- a/src/nvim/ex_cmds.lua
+++ b/src/nvim/ex_cmds.lua
@@ -631,7 +631,7 @@ module.cmds = {
},
{
command='const',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM, CMDWIN),
+ flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN),
addr_type='ADDR_NONE',
func='ex_const',
},
diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua
index 85c9c690f9..ca1b5e8907 100644
--- a/test/functional/vimscript/let_spec.lua
+++ b/test/functional/vimscript/let_spec.lua
@@ -5,6 +5,7 @@ local clear = helpers.clear
local command = helpers.command
local eval = helpers.eval
local meths = helpers.meths
+local exec = helpers.exec
local exec_capture = helpers.exec_capture
local source = helpers.source
local testprg = helpers.testprg
@@ -91,3 +92,19 @@ describe(':let', function()
eq(1, eval('1'))
end)
end)
+
+describe(':let and :const', function()
+ it('have the same output when called without arguments', function()
+ eq(exec_capture('let'), exec_capture('const'))
+ end)
+
+ it('can be used in sandbox', function()
+ exec([[
+ func Func()
+ let l:foo = 'foo'
+ const l:bar = 'bar'
+ endfunc
+ sandbox call Func()
+ ]])
+ end)
+end)