aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/runtime.c13
-rw-r--r--test/functional/core/startup_spec.lua11
-rw-r--r--test/functional/fixtures/middle/filen.lua1
3 files changed, 14 insertions, 11 deletions
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index d87f8f9803..7b72efce23 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -341,12 +341,12 @@ static void expand_pack_entry(RuntimeSearchPath *search_path, CharVec *after_pat
char_u *pack_entry)
{
static char_u buf[MAXPATHL], buf2[MAXPATHL];
- char *start_dir = "/pack/*/start/*/"; // NOLINT
+ char *start_dir = "/pack/*/start/*"; // NOLINT
if (STRLEN(pack_entry) + STRLEN(start_dir) + 1 < MAXPATHL) {
xstrlcpy((char *)buf, (char *)pack_entry, MAXPATHL);
xstrlcpy((char *)buf2, (char *)pack_entry, MAXPATHL);
xstrlcat((char *)buf, start_dir, sizeof buf);
- xstrlcat((char *)buf2, "/start/*/", sizeof buf); // NOLINT
+ xstrlcat((char *)buf2, "/start/*", sizeof buf); // NOLINT
int num_files;
char_u **files;
@@ -354,12 +354,12 @@ static void expand_pack_entry(RuntimeSearchPath *search_path, CharVec *after_pat
if (gen_expand_wildcards(2, pat, &num_files, &files, EW_DIR) == OK) {
for (int i = 0; i < num_files; i++) {
push_path(search_path, xstrdup((char *)files[i]), false);
- size_t after_size = STRLEN(files[i])+6;
+ size_t after_size = STRLEN(files[i])+7;
char *after = xmallocz(after_size);
xstrlcpy(after, (char *)files[i], after_size);
- xstrlcat(after, "after/", after_size);
+ xstrlcat(after, "/after", after_size);
if (os_isdir((char_u *)after)) {
- push_path(search_path, after, true);
+ kv_push(*after_path, after);
} else {
xfree(after);
}
@@ -420,7 +420,7 @@ RuntimeSearchPath runtime_search_path_build(void)
}
for (size_t i = 0; i < kv_size(pack_entries); i++) {
- handle_T h = map_get(String, handle_T)(&pack_used, cstr_as_string((char *)buf));
+ handle_T h = map_get(String, handle_T)(&pack_used, kv_A(pack_entries, i));
if (h == 0) {
expand_pack_entry(&search_path, &after_path, (char_u *)kv_A(pack_entries, i).data);
}
@@ -439,6 +439,7 @@ RuntimeSearchPath runtime_search_path_build(void)
// strings are not owned
kv_destroy(pack_entries);
+ kv_destroy(after_path);
map_destroy(String, handle_T)(&pack_used);
return search_path;
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index c0d9bf4539..1d83eb799f 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -310,7 +310,8 @@ describe('startup', function()
end)
local function pack_clear(cmd)
- clear{args={'--cmd', 'set packpath=test/functional/fixtures', '--cmd', cmd}, env={XDG_CONFIG_HOME='test/functional/fixtures/'}}
+ -- add packages after config dir in rtp but before config/after
+ clear{args={'--cmd', 'set packpath=test/functional/fixtures', '--cmd', 'let paths=split(&rtp, ",")', '--cmd', 'let &rtp = paths[0]..",test/functional/fixtures,test/functional/fixtures/middle,"..join(paths[1:],",")', '--cmd', cmd}, env={XDG_CONFIG_HOME='test/functional/fixtures/'}}
end
@@ -351,18 +352,18 @@ describe('startup', function()
it("handles the correct order with start packages and after/", function()
pack_clear [[ lua _G.test_loadorder = {} vim.cmd "runtime! filen.lua" ]]
- eq({'ordinary', 'FANCY', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ eq({'ordinary', 'FANCY', 'mittel', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
end)
it("handles the correct order with opt packages and after/", function()
pack_clear [[ lua _G.test_loadorder = {} vim.cmd "packadd! superspecial\nruntime! filen.lua" ]]
- eq({'ordinary', 'SuperSpecial', 'FANCY', 'FANCY after', 'SuperSpecial after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ eq({'ordinary', 'SuperSpecial', 'FANCY', 'mittel', 'FANCY after', 'SuperSpecial after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
end)
it("handles the correct order with a package that changes packpath", function()
pack_clear [[ lua _G.test_loadorder = {} vim.cmd "packadd! funky\nruntime! filen.lua" ]]
- eq({'ordinary', 'funky!', 'FANCY', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
- eq({'ordinary', 'funky!', 'ordinary after'}, exec_lua [[ return _G.nested_order ]])
+ 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)
end)
diff --git a/test/functional/fixtures/middle/filen.lua b/test/functional/fixtures/middle/filen.lua
new file mode 100644
index 0000000000..fce50cc776
--- /dev/null
+++ b/test/functional/fixtures/middle/filen.lua
@@ -0,0 +1 @@
+table.insert(_G.test_loadorder, "mittel")