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

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:41:47 -07:00
committed by GitHub
parent 2a8d80a442
commit 6a44055a71
5 changed files with 12 additions and 11 deletions

View File

@@ -1,6 +1,8 @@
local M = {}
local iswin = vim.uv.os_uname().sysname == 'Windows_NT'
-- Can't use `has('win32')` because the `nvim -ll` test runner doesn't support `vim.fn` yet.
local sysname = vim.uv.os_uname().sysname:lower()
local iswin = not not (sysname:find('windows') or sysname:find('mingw'))
local os_sep = iswin and '\\' or '/'
--- Iterate over all the parents of the given path.