fix: use canonical path in windows (#977)

This commit is contained in:
Xavier Young
2022-02-15 15:36:53 +08:00
committed by GitHub
parent fdf63e572d
commit 121f5c9037
2 changed files with 12 additions and 1 deletions

View File

@@ -3,6 +3,8 @@ local uv = vim.loop
local M = {}
M.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win32unix") == 1
function M.path_to_matching_str(path)
return path:gsub('(%-)', '(%%-)'):gsub('(%.)', '(%%.)'):gsub('(%_)', '(%%_)')
end
@@ -208,4 +210,13 @@ function M.file_exists(path)
return error == nil
end
--- @param path string
--- @return string
function M.canonical_path(path)
if M.is_windows and path:match '^%a:' then
return path:sub(1, 1):upper() .. path:sub(2)
end
return path
end
return M