aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/runtime.c15
-rw-r--r--test/functional/core/startup_spec.lua5
2 files changed, 13 insertions, 7 deletions
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index 5ade6244f9..9dfd8547fc 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -439,16 +439,16 @@ static void expand_rtp_entry(RuntimeSearchPath *search_path, Map(String, handle_
}
static void expand_pack_entry(RuntimeSearchPath *search_path, Map(String, handle_T) *rtp_used,
- CharVec *after_path, char_u *pack_entry)
+ CharVec *after_path, char_u *pack_entry, size_t pack_entry_len)
{
static char buf[MAXPATHL];
char *(start_pat[]) = { "/pack/*/start/*", "/start/*" }; // NOLINT
for (int i = 0; i < 2; i++) {
- if (STRLEN(pack_entry) + STRLEN(start_pat[i]) + 1 > MAXPATHL) {
+ if (pack_entry_len + STRLEN(start_pat[i]) + 1 > sizeof buf) {
continue;
}
- STRLCPY(buf, pack_entry, MAXPATHL);
- xstrlcat(buf, start_pat[i], sizeof buf);
+ STRLCPY(buf, pack_entry, sizeof buf);
+ STRLCPY(buf + pack_entry_len, start_pat[i], sizeof buf - pack_entry_len);
expand_rtp_entry(search_path, rtp_used, buf, false);
size_t after_size = STRLEN(buf)+7;
char *after = xmallocz(after_size);
@@ -507,14 +507,15 @@ RuntimeSearchPath runtime_search_path_build(void)
handle_T *h = map_ref(String, handle_T)(&pack_used, cstr_as_string((char *)buf), false);
if (h) {
(*h)++;
- expand_pack_entry(&search_path, &rtp_used, &after_path, buf);
+ expand_pack_entry(&search_path, &rtp_used, &after_path, buf, buflen);
}
}
for (size_t i = 0; i < kv_size(pack_entries); i++) {
- handle_T h = map_get(String, handle_T)(&pack_used, kv_A(pack_entries, i));
+ String item = kv_A(pack_entries, i);
+ handle_T h = map_get(String, handle_T)(&pack_used, item);
if (h == 0) {
- expand_pack_entry(&search_path, &rtp_used, &after_path, (char_u *)kv_A(pack_entries, i).data);
+ expand_pack_entry(&search_path, &rtp_used, &after_path, (char_u *)item.data, item.size);
}
}
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index cc6e2c8067..d1dce0f8da 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -414,6 +414,11 @@ describe('startup', function()
eq({'ordinary', 'funky!', 'FANCY', 'mittel', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
eq({'ordinary', 'funky!', 'mittel', 'ordinary after'}, exec_lua [[ return _G.nested_order ]])
end)
+
+ it("handles the correct order when prepending packpath", function()
+ clear{args={'--cmd', 'set packpath^=test/functional/fixtures', '--cmd', [[ lua _G.test_loadorder = {} vim.cmd "runtime! filen.lua" ]]}, env={XDG_CONFIG_HOME='test/functional/fixtures/'}}
+ eq({'ordinary', 'FANCY', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ end)
end)
describe('sysinit', function()