Skip to content

Commit

Permalink
fix: escape path on windows when opening file (#1023)
Browse files Browse the repository at this point in the history
fixes #889
  • Loading branch information
miversen33 authored Jul 3, 2023
1 parent f765e75 commit 7f6fa04
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lua/neo-tree/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ M.open_file = function(state, path, open_cmd, bufnr)
end

if M.truthy(path) then
local escaped_path = vim.fn.fnameescape(path)
local escaped_path = M.escape_path(path)
local bufnr_or_path = bufnr or escaped_path
local events = require("neo-tree.events")
local result = true
Expand Down Expand Up @@ -897,6 +897,14 @@ M.windowize_path = function(path)
return path:gsub("/", "\\")
end

M.escape_path = function(path)
local escaped_path = vim.fn.fnameescape(path)
if M.is_windows then
escaped_path = escaped_path:gsub("\\", "/")
end
return escaped_path
end

M.wrap = function(func, ...)
if type(func) ~= "function" then
error("Expected function, got " .. type(func))
Expand Down

0 comments on commit 7f6fa04

Please sign in to comment.