mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
fix(startup): "nvim -l foo.lua" may not set arg0 #24161
Problem: Using "nvim -l args.lua" without passing extra script args, does not set `_G.arg[0]`. Steps to reproduce: ``` cat > args.lua<<EOF vim.print(_G.arg, '') vim.print(vim.v.argv, '') EOF nvim --clean -l args.lua ``` Solution: Fix condition in command_line_scan.
This commit is contained in:
parent
b6878f5d63
commit
aa65bd478a
@ -1361,7 +1361,7 @@ static void command_line_scan(mparm_T *parmp)
|
|||||||
}
|
}
|
||||||
parmp->luaf = argv[0];
|
parmp->luaf = argv[0];
|
||||||
argc--;
|
argc--;
|
||||||
if (argc > 0) { // Lua args after "-l <file>".
|
if (argc >= 0) { // Lua args after "-l <file>".
|
||||||
parmp->lua_arg0 = parmp->argc - argc;
|
parmp->lua_arg0 = parmp->argc - argc;
|
||||||
argc = 0;
|
argc = 0;
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,18 @@ describe('startup', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('sets _G.arg', function()
|
it('sets _G.arg', function()
|
||||||
|
-- nvim -l foo.lua
|
||||||
|
assert_l_out([[
|
||||||
|
bufs:
|
||||||
|
nvim args: 3
|
||||||
|
lua args: {
|
||||||
|
[0] = "test/functional/fixtures/startup.lua"
|
||||||
|
}]],
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
eq(0, eval('v:shell_error'))
|
||||||
|
|
||||||
-- nvim -l foo.lua [args]
|
-- nvim -l foo.lua [args]
|
||||||
assert_l_out([[
|
assert_l_out([[
|
||||||
bufs:
|
bufs:
|
||||||
|
Loading…
Reference in New Issue
Block a user