Skip to content

Commit 6cb3f6a

Browse files
committed
_normalize_path: removed redundant table.remove in discarding drive path logic which I did not notice.
1 parent d90fc39 commit 6cb3f6a

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

lua/plenary/path.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,23 @@ local function _normalize_path(filename, cwd)
138138

139139
local has = string.find(filename, path.sep .. "..", 1, true) or string.find(filename, ".." .. path.sep, 1, true)
140140

141+
--qqq
142+
--vim.notify("_normalize_path: has = " .. vim.inspect(has), vim.log.levels.WARN)
143+
--!qqq
144+
141145
if has then
142146
local is_abs = is_absolute(filename, path.sep)
147+
--qqq
148+
--vim.notify("_normalize_path: is_abs = " .. vim.inspect(is_abs), vim.log.levels.WARN)
149+
--!qqq
143150
local split_without_disk_name = function(filename_local)
144151
local parts = _split_by_separator(filename_local)
145152
-- Remove disk name part on Windows
146153
if is_abs and (path.sep == "\\" or U.is_msys2) then
154+
--qqq
155+
--vim.notify("_normalize_path: parts = " .. vim.inspect(parts), vim.log.levels.WARN)
156+
--!qqq
147157
table.remove(parts, 1)
148-
table.remove(parts, 1)
149-
--table.remove(parts, 1)
150158
end
151159
return parts
152160
end
@@ -188,6 +196,10 @@ local function _normalize_path(filename, cwd)
188196
return out_file
189197
end
190198

199+
--qqq
200+
--vim.notify("_normalize_path: call returned " .. vim.inspect(_normalize_path("C:\\msys64\\home\\..\\123", "C:\\msys64\\123")), vim.log.levels.WARN)
201+
--!qqq
202+
191203
local clean = function(pathname)
192204
if is_uri(pathname) then
193205
return pathname

lua/plenary/utils.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,27 @@ function M.posix_to_windows(posix_path)
9292
-- Idk if WezTerm paths behaviour leaks to msys2 actually...
9393
if not prefix_changed then
9494
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)
95+
--vim.notify("Only '/[A-Za-z]' case: " .. posix_path, vim.log.levels.WARN)
9696
posix_path = posix_path:gsub("^/([A-Za-z])", "%1:\\")
9797
prefix_changed = true
9898
else
99-
--vim.notify("'[A-Za-z]:?/' case: " .. posix_path, vim.log.levels.WARN)
99+
--vim.notify("'/[A-Za-z]:?/' case: " .. posix_path, vim.log.levels.WARN)
100100
posix_path = posix_path:gsub("^/([A-Za-z]):?/", "%1:\\")
101101
prefix_changed = true
102102
end
103103
end
104104

105-
-- Lets try to be msys2 compliant for testing.
105+
-- Lets try to use posix-style paths for testing.
106106
--posix_path = posix_path:gsub("^/([A-Za-z]):?([^0-9A-Za-z_-]?)", "/%1%2")
107107

108108

109-
-- Replace remaining forward slashes with backslashes.
109+
-- Replace remaining backslashes with forward slashes.
110110
posix_path = posix_path:gsub("/", "\\")
111111

112112
-- 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+
-- cause forward slashes must to be escaped. Need to come up with something
114+
-- cause nvim for windows (even clang64 binary) prefers windows-style paths (with backslashes as well?).
115+
-- UPD. "set shellslash" makes the trick by converting forward slashes to backslashes in shell invocations.
115116
--posix_path = posix_path:gsub("\\", "/")
116117

117118

0 commit comments

Comments
 (0)