vim-patch:8.2.0215: wrong file name shortening

Problem:    Wrong file name shortening. (Ingo Karkat)
Solution:   Better check for path separator. (Yasuhiro Matsumoto,
            closes vim/vim#5583, closes vim/vim#5584)
a78e9c61a0
This commit is contained in:
zeertzjq 2022-02-07 06:48:10 +08:00
parent d457168e3b
commit f47ba10636
2 changed files with 13 additions and 8 deletions

View File

@ -10725,14 +10725,17 @@ repeat:
// even though the path does not have a prefix.
if (fnamencmp(p, dirname, namelen) == 0) {
p += namelen;
while (*p && vim_ispathsep(*p)) {
++p;
}
*fnamep = p;
if (pbuf != NULL) {
xfree(*bufp); // free any allocated file name
*bufp = pbuf;
pbuf = NULL;
if (vim_ispathsep(*p)) {
while (*p && vim_ispathsep(*p)) {
p++;
}
*fnamep = p;
if (pbuf != NULL) {
// free any allocated file name
xfree(*bufp);
*bufp = pbuf;
pbuf = NULL;
}
}
}
} else {

View File

@ -36,6 +36,8 @@ func Test_fnamemodify()
call chdir($HOME . '/XXXXXXXX/a/')
call assert_equal('foo', fnamemodify($HOME . '/XXXXXXXX/a/foo', ':p:~:.'))
call assert_equal('~/XXXXXXXX/b/foo', fnamemodify($HOME . '/XXXXXXXX/b/foo', ':p:~:.'))
call mkdir($HOME . '/XXXXXXXX/a.ext', 'p')
call assert_equal('~/XXXXXXXX/a.ext/foo', fnamemodify($HOME . '/XXXXXXXX/a.ext/foo', ':p:~:.'))
call chdir(cwd)
call delete($HOME . '/XXXXXXXX', 'rf')