fix(completion): complete drive-letter filepath on Windows #36353

Problem:
On MSWIN, file completion (CTRL-X CTRL-F) only works for the current
drive (so not for actual absolute paths), since drive letters are never
included in the completion pattern.

e.g. when completing "F:\Hello" Nvim currently completes "\Hello"
which is relative to the current drive/volume.

vim solves this by adding ':' to the default 'isfname' value on mswin,
but that causes issues as ':' is not a valid windows path char anywhere
_except_ after the drive letter.

Solution:
detect drive letters in front of the path when creating the completion
pattern.
This commit is contained in:
11soda11
2025-10-31 20:33:01 +01:00
committed by GitHub
parent 2b83237b0f
commit b258382176
4 changed files with 26 additions and 6 deletions

View File

@@ -1679,7 +1679,7 @@ char *file_name_in_line(char *line, int col, int options, int count, char *rel_f
// Search forward for the last char of the file name.
// Also allow ":/" when ':' is not in 'isfname'.
len = path_has_drive_letter(ptr) ? 2 : 0;
len = path_has_drive_letter(ptr, strlen(ptr)) ? 2 : 0;
while (vim_isfilec((uint8_t)ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ')
|| ((options & FNAME_HYP) && path_is_url(ptr + len))
|| (is_url && vim_strchr(":?&=", (uint8_t)ptr[len]) != NULL)) {