]> granicus.if.org Git - vim/commitdiff
patch 8.0.1734: package directory not added to 'rtp' if prefix matches v8.0.1734
authorBram Moolenaar <Bram@vim.org>
Wed, 18 Apr 2018 20:18:23 +0000 (22:18 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 18 Apr 2018 20:18:23 +0000 (22:18 +0200)
Problem:    Package directory not added to 'rtp' if prefix matches.
Solution:   Check the match is a full match. (Ozaki Kiichi, closes #2817)
            Also handle different ways of spelling a path.

src/ex_cmds2.c
src/testdir/test_packadd.vim
src/version.c

index 83f09661cce392ae2be8bc700c918afd74e04ca5..394662741611d87f77e278938d2bd61a04e9144b 100644 (file)
@@ -3821,10 +3821,30 @@ static int APP_BOTH;
     static void
 add_pack_plugin(char_u *fname, void *cookie)
 {
-    if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)fname) == NULL)
-       /* directory is not yet in 'runtimepath', add it */
-       if (add_pack_dir_to_rtp(fname) == FAIL)
+    if (cookie != &APP_LOAD)
+    {
+       char_u  *buf = alloc(MAXPATHL);
+       char_u  *p;
+       int     found = FALSE;
+
+       if (buf == NULL)
            return;
+       p = p_rtp;
+       while (*p != NUL)
+       {
+           copy_option_part(&p, buf, MAXPATHL, ",");
+           if (pathcmp((char *)buf, (char *)fname, -1) == 0)
+           {
+               found = TRUE;
+               break;
+           }
+       }
+       vim_free(buf);
+       if (!found)
+           /* directory is not yet in 'runtimepath', add it */
+           if (add_pack_dir_to_rtp(fname) == FAIL)
+               return;
+    }
 
     if (cookie != &APP_ADD_DIR)
        load_pack_plugin(fname);
index 889d77f4145deda2605cfb612d5fb819eeb47e23..64bd8d2b23e608898dd64aaee4c69e96dda4b481 100644 (file)
@@ -40,6 +40,15 @@ func Test_packadd()
   call assert_match('/testdir/Xdir/pack/mine/opt/mytest\($\|,\)', &rtp)
   call assert_match('/testdir/Xdir/pack/mine/opt/mytest/after$', &rtp)
 
+  " NOTE: '/.../opt/myte' forwardly matches with '/.../opt/mytest'
+  call mkdir(fnamemodify(s:plugdir, ':h') . '/myte', 'p')
+  let rtp = &rtp
+  packadd myte
+
+  " Check the path of 'myte' is added
+  call assert_true(len(&rtp) > len(rtp))
+  call assert_match('/testdir/Xdir/pack/mine/opt/myte\($\|,\)', &rtp)
+
   " Check exception
   call assert_fails("packadd directorynotfound", 'E919:')
   call assert_fails("packadd", 'E471:')
index 2cdd9e313f4b45b6263f19d3574e87722a290e21..3abe29a65c94216cdd29901694b57839ae9bedba 100644 (file)
@@ -762,6 +762,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1734,
 /**/
     1733,
 /**/