Problem: fnamemodify() treats ".." and "../" differently.
Solution: Expand ".." properly like how "/.." is treated in 8.2.3388.
(zeertzjq)
closes: #15218
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
if ((force || !mch_isFullName(fname))
&& ((p = vim_strrchr(fname, '/')) == NULL || p != fname))
{
+ if (p == NULL && STRCMP(fname, "..") == 0)
+ // Handle ".." without path separators.
+ p = fname + 2;
/*
* If the file name has a path, change to that directory for a moment,
* and then get the directory (and get back to where we were).
if (p != NULL)
{
if (STRCMP(p, "/..") == 0)
- // for "/path/dir/.." include the "/.."
+ // For "/path/dir/.." include the "/..".
p += 3;
#ifdef HAVE_FCHDIR
let l = findfile('bar', ';../', -1)
call assert_equal(1, len(l))
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
+ let l = findfile('bar', ';..', -1)
+ call assert_equal(1, len(l))
+ call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
let l = findfile('bar', ';' . save_dir . '/Xfinddir1/Xdir2/', -1)
call assert_equal(1, len(l))
let l = findfile('bar', ';../../', -1)
call assert_equal(1, len(l))
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
+ let l = findfile('bar', ';../..', -1)
+ call assert_equal(1, len(l))
+ call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
let l = findfile('bar', ';' . save_dir . '/Xfinddir1/', -1)
call assert_equal(2, len(l))
call assert_equal(2, len(l))
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
call assert_match('.*/Xfinddir1/bar', l[1])
+ let l = findfile('bar', ';../../..', -1)
+ call assert_equal(2, len(l))
+ call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
+ call assert_match('.*/Xfinddir1/bar', l[1])
" Test combined downwards and upwards search from Xdir2/.
cd ../..
call assert_equal($HOME .. "/foo" , fnamemodify('~/foo', ':p'))
call assert_equal(fnamemodify('.', ':p:h:h:h') .. '/', fnamemodify($HOME .. '/../', ':p'))
call assert_equal(fnamemodify('.', ':p:h:h:h') .. '/', fnamemodify($HOME .. '/..', ':p'))
+ call assert_equal(fnamemodify('.', ':p:h:h') .. '/', fnamemodify('../', ':p'))
+ call assert_equal(fnamemodify('.', ':p:h:h') .. '/', fnamemodify('..', ':p'))
call assert_equal('test.out', fnamemodify('test.out', ':.'))
call assert_equal('a', fnamemodify('../testdir/a', ':.'))
call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~'))
call writefile([], 'Xtagsdir1/Xtags', 'D')
cd Xtagsdir1/
- let &tags = './Xtags;' .. fnamemodify('./..', ':p')
+ let &tags = './Xtags;' .. fnamemodify('..', ':p')
call assert_equal(1, len(tagfiles()))
cd Xtagsdir2/
- let &tags = './Xtags;' .. fnamemodify('./..', ':p')
+ let &tags = './Xtags;' .. fnamemodify('..', ':p')
call assert_equal(1, len(tagfiles()))
cd Xtagsdir3/
- let &tags = './Xtags;' .. fnamemodify('./..', ':p')
+ let &tags = './Xtags;' .. fnamemodify('..', ':p')
call assert_equal(0, len(tagfiles()))
let &tags = './Xtags;../'
cd ..
call assert_equal(1, len(tagfiles()))
+ let &tags = './Xtags;..'
+ call assert_equal(1, len(tagfiles()))
+
+ cd Xtagsdir2/
+ call assert_equal(1, len(tagfiles()))
+
+ cd Xtagsdir3/
+ call assert_equal(0, len(tagfiles()))
+
set tags&
call chdir(save_cwd)
endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 569,
/**/
568,
/**/