* Fix escape special characters on windows fixes #2362 * use utils for windows check * Add function to escape special chars on windows * Change escape string function to use and/or * Add nil check in escape special chars function --------- Co-authored-by: Davis Sanders <dsanders@smartlink.city> Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
@@ -270,6 +270,7 @@ local function open_in_new_window(filename, mode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local fname = vim.fn.fnameescape(filename)
|
local fname = vim.fn.fnameescape(filename)
|
||||||
|
fname = utils.escape_special_chars(fname)
|
||||||
|
|
||||||
local cmd
|
local cmd
|
||||||
if create_new_window then
|
if create_new_window then
|
||||||
|
|||||||
@@ -210,6 +210,16 @@ function M.canonical_path(path)
|
|||||||
return path
|
return path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Escapes special characters in string if windows else returns unmodified string.
|
||||||
|
-- @param path string
|
||||||
|
-- @return path
|
||||||
|
function M.escape_special_chars(path)
|
||||||
|
if path == nil then
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
return M.is_windows and path:gsub("%(", "\\("):gsub("%)", "\\)") or path
|
||||||
|
end
|
||||||
|
|
||||||
-- Create empty sub-tables if not present
|
-- Create empty sub-tables if not present
|
||||||
-- @param tbl to create empty inside of
|
-- @param tbl to create empty inside of
|
||||||
-- @param path dot separated string of sub-tables
|
-- @param path dot separated string of sub-tables
|
||||||
|
|||||||
Reference in New Issue
Block a user