Skip to content

Commit 5aa8e64

Browse files
committed
Corrected a mapping case with a custom folders under msys2 root.
Using the same approach we can further refactor it focusing on drive paths conversion first and fallback to msys2 root mapping.
1 parent 00e5b4e commit 5aa8e64

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/plenary/utils.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,16 @@ function M.posix_to_windows(posix_path)
9696
--vim.notify("Only '/[A-Za-z]' case: " .. posix_path, vim.log.levels.WARN)
9797
posix_path = posix_path:gsub("^/([A-Za-z])", "%1:\\")
9898
prefix_changed = true
99-
else
99+
elseif posix_path:find("/[A-Za-z]:?/") then
100100
--vim.notify("'/[A-Za-z]:?/' case: " .. posix_path, vim.log.levels.WARN)
101101
posix_path = posix_path:gsub("^/([A-Za-z]):?/", "%1:\\")
102102
prefix_changed = true
103+
else
104+
-- The code path can be taken only in specific cases
105+
-- like a custom folder under msys2 root (/abc).
106+
--vim.notify("General mapping case for given path: " .. posix_path, vim.log.levels.WARN)
107+
posix_path = posix_path:gsub("^/", M.msys2_root .. "\\")
108+
prefix_changed = true
103109
end
104110
end
105111

@@ -123,6 +129,8 @@ function M.posix_to_windows(posix_path)
123129
end
124130

125131

132+
--vim.notify("posix_to_windows will return " .. posix_path, vim.log.levels.WARN)
133+
126134
return posix_path
127135
end
128136

0 commit comments

Comments
 (0)