fix(vim.fs): dirname() returns "." on mingw/msys2 #30480

Problem:
`vim.fs.dirname([[C:\User\XXX\AppData\Local]])` returns "." on
mingw/msys2.

Solution:
- Check for "mingw" when deciding `iswin`.
- Use `has("win32")` where possible, it works in "fast" contexts since
  b02eeb6a72.
This commit is contained in:
Justin M. Keyes
2024-09-23 06:05:58 -07:00
committed by GitHub
parent 5acdc4499e
commit 47e6b2233f
5 changed files with 12 additions and 11 deletions

View File

@ -392,7 +392,7 @@ function M.check_logs()
)
end
function M.sysname()
local function sysname()
return uv.os_uname().sysname:lower()
end
@ -403,11 +403,11 @@ function M.is_os(s)
error('unknown platform: ' .. tostring(s))
end
return not not (
(s == 'win' and (M.sysname():find('windows') or M.sysname():find('mingw')))
or (s == 'mac' and M.sysname() == 'darwin')
or (s == 'freebsd' and M.sysname() == 'freebsd')
or (s == 'openbsd' and M.sysname() == 'openbsd')
or (s == 'bsd' and M.sysname():find('bsd'))
(s == 'win' and (sysname():find('windows') or sysname():find('mingw')))
or (s == 'mac' and sysname() == 'darwin')
or (s == 'freebsd' and sysname() == 'freebsd')
or (s == 'openbsd' and sysname() == 'openbsd')
or (s == 'bsd' and sysname():find('bsd'))
)
end