mirror of
https://github.com/neovim/neovim.git
synced 2026-06-15 16:23:48 +00:00
fix(path): nvim_get_runtime_file fails on DOS 8.3 filename #40144
Problem:
stdpath() may return a DOS 8.3 "shortened" filename, because Windows
truncates some long usernames into `6ch~N` names. Then features such
as `nvim_get_runtime_file` fail to find the file.
Analysis:
When expanding an 8.3 filename path like `C:/Users/ADMINI~1/AppData/*`,
we treat `~` as a special character and first check whether a directory
named `ADMINI~1` exists under `Users`. Since no such directory actually
exists, the expansion fails.
Solution:
Treat `~` as a literal character in `do_path_expand`. Since the `~/`
case is already handled in `gen_expand_wildcards`, any remaining `~` is
just a literal character and will later be escaped to `\~` by
`file_pat_to_reg_pat` if needed.
This commit is contained in:
@@ -687,7 +687,9 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
|
||||
s = p + 1;
|
||||
} else if (path_end >= path + wildoff
|
||||
#ifdef MSWIN
|
||||
&& vim_strchr("*?[~", (uint8_t)(*path_end)) != NULL
|
||||
// "~" not included here, we want to treat it as literal.
|
||||
// The "~/" case is already handled in `gen_expand_wildcards`.
|
||||
&& vim_strchr("*?[", (uint8_t)(*path_end)) != NULL
|
||||
#else
|
||||
&& (vim_strchr("*?[{~$", (uint8_t)(*path_end)) != NULL
|
||||
|| (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char(path_end))))
|
||||
|
||||
Reference in New Issue
Block a user