aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/main.c2
-rw-r--r--test/functional/core/startup_spec.lua12
2 files changed, 13 insertions, 1 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 83e56c3066..9b364f8c35 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -1361,7 +1361,7 @@ static void command_line_scan(mparm_T *parmp)
}
parmp->luaf = argv[0];
argc--;
- if (argc > 0) { // Lua args after "-l <file>".
+ if (argc >= 0) { // Lua args after "-l <file>".
parmp->lua_arg0 = parmp->argc - argc;
argc = 0;
}
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index 58bf7f8681..ef3c2eadd9 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -144,6 +144,18 @@ describe('startup', function()
end)
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]
assert_l_out([[
bufs: