Revert "fix(#2862): windows path replaces backslashes with forward slashes (#2903)"

This reverts commit 45a93d9979.
This commit is contained in:
ljie-PI
2024-10-19 14:35:00 +08:00
parent 2a268f631d
commit 25d4f14b90
2 changed files with 9 additions and 10 deletions

View File

@@ -331,9 +331,9 @@ local function open_in_new_window(filename, mode)
local fname
if M.relative_path then
fname = vim.fn.fnameescape(utils.path_relative(filename, vim.fn.getcwd()))
fname = utils.escape_special_chars(vim.fn.fnameescape(utils.path_relative(filename, vim.fn.getcwd())))
else
fname = vim.fn.fnameescape(filename)
fname = utils.escape_special_chars(vim.fn.fnameescape(filename))
end
local command
@@ -370,28 +370,27 @@ end
---@param mode string
---@param filename string
function M.fn(mode, filename)
local fname = utils.escape_special_chars(filename)
if type(mode) ~= "string" then
mode = ""
end
if mode == "tabnew" then
return open_file_in_tab(fname)
return open_file_in_tab(filename)
end
if mode == "drop" then
return drop(fname)
return drop(filename)
end
if mode == "tab_drop" then
return tab_drop(fname)
return tab_drop(filename)
end
if mode == "edit_in_place" then
return edit_in_current_buf(fname)
return edit_in_current_buf(filename)
end
local buf_loaded = is_already_loaded(fname)
local buf_loaded = is_already_loaded(filename)
local found_win = utils.get_win_buf_from_path(filename)
if found_win and (mode == "preview" or mode == "preview_no_picker") then
@@ -399,7 +398,7 @@ function M.fn(mode, filename)
end
if not found_win then
open_in_new_window(fname, mode)
open_in_new_window(filename, mode)
else
vim.api.nvim_set_current_win(found_win)
vim.bo.bufhidden = ""

View File

@@ -279,7 +279,7 @@ function M.escape_special_chars(path)
if path == nil then
return path
end
return M.is_windows and path:gsub("\\", "/") or path
return M.is_windows and path:gsub("%(", "\\("):gsub("%)", "\\)") or path
end
--- Create empty sub-tables if not present