mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
d457168e3b
commit
f47ba10636
@ -10725,16 +10725,19 @@ repeat:
|
||||
// even though the path does not have a prefix.
|
||||
if (fnamencmp(p, dirname, namelen) == 0) {
|
||||
p += namelen;
|
||||
if (vim_ispathsep(*p)) {
|
||||
while (*p && vim_ispathsep(*p)) {
|
||||
++p;
|
||||
p++;
|
||||
}
|
||||
*fnamep = p;
|
||||
if (pbuf != NULL) {
|
||||
xfree(*bufp); // free any allocated file name
|
||||
// free any allocated file name
|
||||
xfree(*bufp);
|
||||
*bufp = pbuf;
|
||||
pbuf = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
home_replace(NULL, p, dirname, MAXPATHL, true);
|
||||
// Only replace it when it starts with '~'
|
||||
|
@ -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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user