diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 85588ed876..820e5cdc3d 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -1227,7 +1227,7 @@ bool os_fileinfo2(const char *path, FileInfo *info) info->rest_off = (size_t)(p - path); return true; } - if (p[0] == '?' || p[0] == '.') { + if (leading_slashes >= 2 && (p[0] == '?' || p[0] == '.')) { if (!vim_ispathsep_nocolon(p[1])) { return true; } diff --git a/test/functional/vimscript/fnamemodify_spec.lua b/test/functional/vimscript/fnamemodify_spec.lua index 65a1ec72e9..c9b93dd31d 100644 --- a/test/functional/vimscript/fnamemodify_spec.lua +++ b/test/functional/vimscript/fnamemodify_spec.lua @@ -182,6 +182,11 @@ describe('fnamemodify()', function() eq('//?/UNC/server', fnamemodify('//?/UNC/server', ':h')) eq('//?/UNC/server/share', fnamemodify('//?/UNC/server/share', ':h')) eq('//?/UNC/server/share/', fnamemodify('//?/UNC/server/share/foo', ':h')) + + -- relative "./" and ".\" prefixes + eq('./path/to', fnamemodify('./path/to/hello.txt', ':h')) + eq('./path', fnamemodify('./path/to/hello.txt', ':h:h')) + eq('./path/to', fnamemodify([[.\path\to\hello.txt]], ':h')) end end)