mirror of
https://github.com/neovim/neovim.git
synced 2025-12-03 07:23:05 +00:00
vim-patch:8.2.0208: fnamemodify() does not apply ":~" when followed by ":."
Problem: Fnamemodify() does not apply ":~" when followed by ":.".
Solution: Don't let a failing ":." cause the ":~" to be skipped. (Yasuhiro
Matsumoto, closes vim/vim#5577)
d816cd94d8
This commit is contained in:
@@ -10624,12 +10624,13 @@ int modify_fname(char_u *src, bool tilde_file, size_t *usedlen, char_u **fnamep,
|
||||
char_u *s, *p, *pbuf;
|
||||
char_u dirname[MAXPATHL];
|
||||
int c;
|
||||
int has_fullname = 0;
|
||||
bool has_fullname = false;
|
||||
bool has_homerelative = false;
|
||||
|
||||
repeat:
|
||||
// ":p" - full path/file_name
|
||||
if (src[*usedlen] == ':' && src[*usedlen + 1] == 'p') {
|
||||
has_fullname = 1;
|
||||
has_fullname = true;
|
||||
|
||||
valid |= VALID_PATH;
|
||||
*usedlen += 2;
|
||||
@@ -10698,7 +10699,7 @@ repeat:
|
||||
}
|
||||
pbuf = NULL;
|
||||
// Need full path first (use expand_env() to remove a "~/")
|
||||
if (!has_fullname) {
|
||||
if (!has_fullname && !has_homerelative) {
|
||||
if (c == '.' && **fnamep == '~') {
|
||||
p = pbuf = expand_env_save(*fnamep);
|
||||
} else {
|
||||
@@ -10708,14 +10709,26 @@ repeat:
|
||||
p = *fnamep;
|
||||
}
|
||||
|
||||
has_fullname = 0;
|
||||
has_fullname = false;
|
||||
|
||||
if (p != NULL) {
|
||||
if (c == '.') {
|
||||
os_dirname(dirname, MAXPATHL);
|
||||
s = path_shorten_fname(p, dirname);
|
||||
if (s != NULL) {
|
||||
*fnamep = s;
|
||||
if (has_homerelative) {
|
||||
s = vim_strsave(dirname);
|
||||
home_replace(NULL, s, dirname, MAXPATHL, true);
|
||||
xfree(s);
|
||||
}
|
||||
size_t namelen = STRLEN(dirname);
|
||||
|
||||
// Do not call shorten_fname() here since it removes the prefix
|
||||
// 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;
|
||||
@@ -10730,6 +10743,7 @@ repeat:
|
||||
*fnamep = s;
|
||||
xfree(*bufp);
|
||||
*bufp = s;
|
||||
has_homerelative = true;
|
||||
}
|
||||
}
|
||||
xfree(pbuf);
|
||||
|
||||
Reference in New Issue
Block a user