fix(windows): file operation preview uses only backslash path separator (#336)

This commit is contained in:
Steven Arcangeli 2024-04-23 20:20:58 -07:00
parent be0a1ecbf0
commit 96f0983e75
2 changed files with 10 additions and 4 deletions

View file

@ -40,7 +40,7 @@ end
M.to_short_os_path = function(path, entry_type) M.to_short_os_path = function(path, entry_type)
local shortpath = fs.shorten_path(fs.posix_to_os_path(path)) local shortpath = fs.shorten_path(fs.posix_to_os_path(path))
if entry_type == "directory" then if entry_type == "directory" then
shortpath = util.addslash(shortpath) shortpath = util.addslash(shortpath, true)
end end
return shortpath return shortpath
end end

View file

@ -337,10 +337,16 @@ M.set_highlights = function(bufnr, highlights)
end end
---@param path string ---@param path string
---@param os_slash? boolean use os filesystem slash instead of posix slash
---@return string ---@return string
M.addslash = function(path) M.addslash = function(path, os_slash)
if not vim.endswith(path, "/") then local slash = "/"
return path .. "/" if os_slash and require("oil.fs").is_windows then
slash = "\\"
end
if not vim.endswith(path, slash) then
return path .. slash
else else
return path return path
end end