@@ -59,7 +59,7 @@ function M.posix_to_windows(posix_path)
59
59
60
60
61
61
-- For edgy-ephemeral cases when vim.fn.expand() eats posix-style path.
62
- -- In that case we get forward slashes everywhere which we don't need
62
+ -- In that case we get backslashes everywhere which we don't need
63
63
-- when working with libuv which uses WinAPI under the hood.
64
64
-- E.g. vim.fn.expand("/home/User") gives "\home\User".
65
65
posix_path = posix_path :gsub (" \\ " , " /" )
@@ -89,29 +89,31 @@ function M.posix_to_windows(posix_path)
89
89
90
90
-- Drive letter paths /c/Users -> C:\\Users (+edge case on fast pane split in WezTerm /C:/Users -> C:\\Users).
91
91
-- It is possible to have only "/c" (w/o trailing "/") but not "/C:" (WezTerm internally trails it with "/").
92
- -- Idk if WezTerm paths behaviour leaks to msys2 actually...
92
+ -- Idk if WezTerm paths behaviour leaks to msys2 actually cause even in regular cmd.exe/powershell.exe it uses
93
+ -- "/<DRIVE>:/" notation internally for panes.
93
94
if not prefix_changed then
94
95
if # posix_path == 2 and posix_path :find (" /[A-Za-z]" ) then
95
- -- vim.notify("Only '[A-Za-z]: ' case: " .. posix_path, vim.log.levels.WARN)
96
+ -- vim.notify("Only '/ [A-Za-z]' case: " .. posix_path, vim.log.levels.WARN)
96
97
posix_path = posix_path :gsub (" ^/([A-Za-z])" , " %1:\\ " )
97
98
prefix_changed = true
98
99
else
99
- -- vim.notify("'[A-Za-z]:?/' case: " .. posix_path, vim.log.levels.WARN)
100
+ -- vim.notify("'/ [A-Za-z]:?/' case: " .. posix_path, vim.log.levels.WARN)
100
101
posix_path = posix_path :gsub (" ^/([A-Za-z]):?/" , " %1:\\ " )
101
102
prefix_changed = true
102
103
end
103
104
end
104
105
105
- -- Lets try to be msys2 compliant for testing.
106
+ -- Lets try to use posix-style paths for testing.
106
107
-- posix_path = posix_path:gsub("^/([A-Za-z]):?([^0-9A-Za-z_-]?)", "/%1%2")
107
108
108
109
109
110
-- Replace remaining forward slashes with backslashes.
110
111
posix_path = posix_path :gsub (" /" , " \\ " )
111
112
112
- -- For bash.exe (nvim shell) it is better to use backslashes
113
- -- cause forward slashes must be escaped. Need to come up with something
114
- -- cause nvim for windows (even clang64 binary) prefers windows-style paths (with backslashes?).
113
+ -- For bash.exe (nvim shell) it is better to use forward slashes
114
+ -- cause backslashes must to be escaped. Need to come up with something
115
+ -- cause nvim for windows (even clang64 binary) prefers windows-style paths (but works with forward slashes as well?).
116
+ -- UPD. "set shellslash" makes the trick by converting backslashes to forward slashes in shell invocations.
115
117
-- posix_path = posix_path:gsub("\\", "/")
116
118
117
119
0 commit comments