From 7f6fa04dbd8e8c79d1af33bc90e856b65d8641da Mon Sep 17 00:00:00 2001 From: Mike Iversen Date: Sun, 2 Jul 2023 22:49:12 -0500 Subject: [PATCH] fix: escape path on windows when opening file (#1023) fixes #889 --- lua/neo-tree/utils.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/neo-tree/utils.lua b/lua/neo-tree/utils.lua index 38c939cc..b9b26913 100644 --- a/lua/neo-tree/utils.lua +++ b/lua/neo-tree/utils.lua @@ -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 @@ -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))