mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 09:56:31 +00:00
fix(excmd): :trust executed even when inside false condition (#36032)
Problem: :trust is executed even when inside false condition. Solution: Make skip_cmd() return true for CMD_trust, as ex_trust() does not handle eap->skip itself.
This commit is contained in:
@@ -1714,8 +1714,8 @@ mark a file as trusted or untrusted using the |:trust| command or the
|
|||||||
contents. The trust list is stored on disk, Nvim will
|
contents. The trust list is stored on disk, Nvim will
|
||||||
re-use it after restarting.
|
re-use it after restarting.
|
||||||
|
|
||||||
[++deny] marks [file] (or current buffer if no [file]) as
|
[++deny] marks [file] (or current buffer if no [file])
|
||||||
untrusted: it will never be executed, 'exrc' will
|
as untrusted: it will never be executed, 'exrc' will
|
||||||
ignore it.
|
ignore it.
|
||||||
|
|
||||||
[++remove] removes [file] (or current buffer if no
|
[++remove] removes [file] (or current buffer if no
|
||||||
|
@@ -1951,7 +1951,6 @@ static bool skip_cmd(const exarg_T *eap)
|
|||||||
case CMD_throw:
|
case CMD_throw:
|
||||||
case CMD_tilde:
|
case CMD_tilde:
|
||||||
case CMD_topleft:
|
case CMD_topleft:
|
||||||
case CMD_trust:
|
|
||||||
case CMD_unlet:
|
case CMD_unlet:
|
||||||
case CMD_unlockvar:
|
case CMD_unlockvar:
|
||||||
case CMD_verbose:
|
case CMD_verbose:
|
||||||
|
@@ -13,21 +13,21 @@ local fn = n.fn
|
|||||||
describe(':trust', function()
|
describe(':trust', function()
|
||||||
local xstate = 'Xstate'
|
local xstate = 'Xstate'
|
||||||
|
|
||||||
setup(function()
|
|
||||||
n.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
|
|
||||||
end)
|
|
||||||
|
|
||||||
teardown(function()
|
|
||||||
n.rmdir(xstate)
|
|
||||||
end)
|
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
n.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
|
||||||
t.write_file('test_file', 'test')
|
t.write_file('test_file', 'test')
|
||||||
clear { env = { XDG_STATE_HOME = xstate } }
|
clear { env = { XDG_STATE_HOME = xstate } }
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
os.remove('test_file')
|
os.remove('test_file')
|
||||||
|
n.rmdir(xstate)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('is not executed when inside false condition', function()
|
||||||
|
command('edit test_file')
|
||||||
|
eq('', exec_capture('if 0 | trust | endif'))
|
||||||
|
eq(nil, vim.uv.fs_stat(fn.stdpath('state') .. pathsep .. 'trust'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('trust then deny then remove a file using current buffer', function()
|
it('trust then deny then remove a file using current buffer', function()
|
||||||
|
Reference in New Issue
Block a user