aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-07-08 00:05:35 -0400
committerJames McCoy <jamessan@jamessan.com>2016-07-08 01:45:21 -0400
commit520a4f06e20c3917e75e3a413a290d9141cb0a0c (patch)
tree10a25121e60a970da9bc9e7bf7471e1856be8f94
parente686b613ecd349265e17d9c1f481cafac4935aef (diff)
downloadrneovim-520a4f06e20c3917e75e3a413a290d9141cb0a0c.tar.gz
rneovim-520a4f06e20c3917e75e3a413a290d9141cb0a0c.tar.bz2
rneovim-520a4f06e20c3917e75e3a413a290d9141cb0a0c.zip
vim-patch:7.4.1840
Problem: When using packages an "after" directory cannot be used. Solution: Add the "after" directory of the package to 'runtimepath' if it exists. https://github.com/vim/vim/commit/a57024453115592b8847af40ddd965a33898e390
-rw-r--r--src/nvim/ex_cmds2.c22
-rw-r--r--src/nvim/version.c1
-rw-r--r--test/functional/legacy/packadd_spec.lua2
3 files changed, 20 insertions, 5 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 900932fbed..56f0ca0904 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -2468,7 +2468,7 @@ static void add_pack_plugin(char_u *fname, void *cookie)
}
if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)ffname) == NULL) {
- // directory not in 'runtimepath', add it
+ // directory is not yet in 'runtimepath', add it
p4 = p3 = p2 = p1 = get_past_head(ffname);
for (p = p1; *p; mb_ptr_adv(p)) {
if (vim_ispathsep_nocolon(*p)) {
@@ -2496,22 +2496,34 @@ static void add_pack_plugin(char_u *fname, void *cookie)
}
*p4 = c;
+ // check if rtp/pack/name/start/name/after exists
+ char *afterdir = concat_fnames((char *)ffname, "after", true);
+ size_t afterlen = 0;
+ if (os_isdir((char_u *)afterdir)) {
+ afterlen = STRLEN(afterdir) + 1; // add one for comma
+ }
+
size_t oldlen = STRLEN(p_rtp);
- size_t addlen = STRLEN(ffname);
- new_rtp = try_malloc(oldlen + addlen + 1);
+ size_t addlen = STRLEN(ffname) + 1; // add one for comma
+ new_rtp = try_malloc(oldlen + addlen + afterlen + 1); // add one for NUL
if (new_rtp == NULL) {
goto theend;
}
uintptr_t keep = (uintptr_t)(insp - p_rtp);
memmove(new_rtp, p_rtp, keep);
new_rtp[keep] = ',';
- memmove(new_rtp + keep + 1, ffname, addlen + 1);
+ memmove(new_rtp + keep + 1, ffname, addlen);
if (p_rtp[keep] != NUL) {
- memmove(new_rtp + keep + 1 + addlen, p_rtp + keep,
+ memmove(new_rtp + keep + addlen, p_rtp + keep,
oldlen - keep + 1);
}
+ if (afterlen > 0) {
+ STRCAT(new_rtp, ",");
+ STRCAT(new_rtp, afterdir);
+ }
set_option_value((char_u *)"rtp", 0L, new_rtp, 0);
xfree(new_rtp);
+ xfree(afterdir);
}
if (cookie != &APP_ADD_DIR) {
diff --git a/src/nvim/version.c b/src/nvim/version.c
index b9543cb0b7..358b2cc2f0 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -76,6 +76,7 @@ static char *features[] = {
// clang-format off
static int included_patches[] = {
1960,
+ 1840,
1832,
1831,
1809,
diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua
index 8c680f24b4..b2ed39f288 100644
--- a/test/functional/legacy/packadd_spec.lua
+++ b/test/functional/legacy/packadd_spec.lua
@@ -27,6 +27,7 @@ describe('packadd', function()
func Test_packadd()
call mkdir(s:plugdir . '/plugin', 'p')
call mkdir(s:plugdir . '/ftdetect', 'p')
+ call mkdir(s:plugdir . '/after', 'p')
set rtp&
let rtp = &rtp
filetype on
@@ -45,6 +46,7 @@ describe('packadd', function()
call assert_true(17, g:ftdetect_works)
call assert_true(len(&rtp) > len(rtp))
call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
+ call assert_true(&rtp =~ (s:plugdir . '/after$'))
" Check exception
call assert_fails("packadd directorynotfound", 'E919:')