mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-03 17:24:29 +00:00 
			
		
		
		
	vim-patch:8.0.0308
Problem:    When using a symbolic link, the package path will not be inserted
            at the right position in 'runtimepath'. (Dugan Chen, Norio Takagi)
Solution:   Resolve symbolic links when finding the right position in
            'runtimepath'. (Hirohito Higashi)
2f9e575583
			
			
This commit is contained in:
		@@ -2498,6 +2498,7 @@ static int APP_BOTH;
 | 
			
		||||
static void add_pack_plugin(char_u *fname, void *cookie)
 | 
			
		||||
{
 | 
			
		||||
  char_u *p4, *p3, *p2, *p1, *p;
 | 
			
		||||
  char_u *buf = NULL;
 | 
			
		||||
 | 
			
		||||
  char *const ffname = fix_fname((char *)fname);
 | 
			
		||||
 | 
			
		||||
@@ -2525,26 +2526,30 @@ static void add_pack_plugin(char_u *fname, void *cookie)
 | 
			
		||||
    // Find "ffname" in "p_rtp", ignoring '/' vs '\' differences
 | 
			
		||||
    size_t fname_len = strlen(ffname);
 | 
			
		||||
    const char *insp = (const char *)p_rtp;
 | 
			
		||||
    for (;;) {
 | 
			
		||||
      if (path_fnamencmp(insp, ffname, fname_len) == 0) {
 | 
			
		||||
    buf = try_malloc(MAXPATHL);
 | 
			
		||||
    if (buf == NULL) {
 | 
			
		||||
      goto theend;
 | 
			
		||||
    }
 | 
			
		||||
    while (*insp != NUL) {
 | 
			
		||||
      copy_option_part((char_u **)&insp, buf, MAXPATHL, ",");
 | 
			
		||||
      add_pathsep((char *)buf);
 | 
			
		||||
      char *const rtp_ffname = fix_fname((char *)buf);
 | 
			
		||||
      if (rtp_ffname == NULL) {
 | 
			
		||||
        goto theend;
 | 
			
		||||
      }
 | 
			
		||||
      bool match = path_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
 | 
			
		||||
      xfree(rtp_ffname);
 | 
			
		||||
      if (match) {
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      insp = strchr(insp, ',');
 | 
			
		||||
      if (insp == NULL) {
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      insp++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (insp == NULL) {
 | 
			
		||||
    if (*insp == NUL) {
 | 
			
		||||
      // not found, append at the end
 | 
			
		||||
      insp = (const char *)p_rtp + STRLEN(p_rtp);
 | 
			
		||||
    } else {
 | 
			
		||||
      // append after the matching directory.
 | 
			
		||||
      insp += strlen(ffname);
 | 
			
		||||
      while (*insp != NUL && *insp != ',') {
 | 
			
		||||
        insp++;
 | 
			
		||||
      }
 | 
			
		||||
      insp--;
 | 
			
		||||
    }
 | 
			
		||||
    *p4 = c;
 | 
			
		||||
 | 
			
		||||
@@ -2614,6 +2619,7 @@ static void add_pack_plugin(char_u *fname, void *cookie)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
theend:
 | 
			
		||||
  xfree(buf);
 | 
			
		||||
  xfree(ffname);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -644,7 +644,7 @@ static const int included_patches[] = {
 | 
			
		||||
  311,
 | 
			
		||||
  // 310,
 | 
			
		||||
  // 309,
 | 
			
		||||
  // 308,
 | 
			
		||||
  308,
 | 
			
		||||
  307,
 | 
			
		||||
  // 306,
 | 
			
		||||
  // 305,
 | 
			
		||||
 
 | 
			
		||||
@@ -83,6 +83,39 @@ describe('packadd', function()
 | 
			
		||||
        call assert_equal(new_rtp, &rtp)
 | 
			
		||||
      endfunc
 | 
			
		||||
 | 
			
		||||
      func Test_packadd_symlink_dir()
 | 
			
		||||
        if !has('unix')
 | 
			
		||||
          return
 | 
			
		||||
        endif
 | 
			
		||||
        let top2_dir = s:topdir . '/Xdir2'
 | 
			
		||||
        let real_dir = s:topdir . '/Xsym'
 | 
			
		||||
        silent !ln -s real_dir top2_dir
 | 
			
		||||
        let &rtp = top2_dir . ',' . top2_dir . '/after'
 | 
			
		||||
        let &packpath = &rtp
 | 
			
		||||
 | 
			
		||||
        let s:plugdir = top2_dir . '/pack/mine/opt/mytest'
 | 
			
		||||
        call mkdir(s:plugdir . '/plugin', 'p')
 | 
			
		||||
 | 
			
		||||
        exe 'split ' . s:plugdir . '/plugin/test.vim'
 | 
			
		||||
        call setline(1, 'let g:plugin_works = 44')
 | 
			
		||||
        wq
 | 
			
		||||
        let g:plugin_works = 0
 | 
			
		||||
 | 
			
		||||
        packadd mytest
 | 
			
		||||
 | 
			
		||||
        " Must have been inserted in the middle, not at the end
 | 
			
		||||
        call assert_true(&rtp =~ '/pack/mine/opt/mytest,')
 | 
			
		||||
        call assert_equal(44, g:plugin_works)
 | 
			
		||||
 | 
			
		||||
        " No change when doing it again.
 | 
			
		||||
        let rtp_before = &rtp
 | 
			
		||||
        packadd mytest
 | 
			
		||||
        call assert_equal(rtp_before, &rtp)
 | 
			
		||||
 | 
			
		||||
        set rtp&
 | 
			
		||||
        let rtp = &rtp
 | 
			
		||||
      endfunc
 | 
			
		||||
 | 
			
		||||
      func Test_packloadall()
 | 
			
		||||
        " plugin foo with an autoload directory
 | 
			
		||||
        let fooplugindir = &packpath . '/pack/mine/start/foo/plugin'
 | 
			
		||||
@@ -227,6 +260,11 @@ describe('packadd', function()
 | 
			
		||||
    expected_empty()
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('works with symlinks', function()
 | 
			
		||||
    call('Test_packadd_symlink_dir')
 | 
			
		||||
    expected_empty()
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('works with :packloadall', function()
 | 
			
		||||
    call('Test_packloadall')
 | 
			
		||||
    expected_empty()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user