Skip to content

Commit aa02bc1

Browse files
authored
Merge branch 'master' into multiinstance-renderer
2 parents b1eb870 + 45a93d9 commit aa02bc1

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

doc/nvim-tree-lua.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ Specify minimum notification level, uses the values from |vim.log.levels|
15761576
`ERROR`: hard errors e.g. failure to read from the file system.
15771577
`WARNING`: non-fatal errors e.g. unable to system open a file.
15781578
`INFO:` information only e.g. file copy path confirmation.
1579-
`DEBUG:` not used.
1579+
`DEBUG:` information for troubleshooting, e.g. failures in some window closing operations.
15801580

15811581
*nvim-tree.notify.absolute_path*
15821582
Whether to use absolute paths or item names in fs action notifications.

lua/nvim-tree/actions/node/open-file.lua

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ local function open_in_new_window(filename, mode)
333333

334334
local fname
335335
if M.relative_path then
336-
fname = utils.escape_special_chars(vim.fn.fnameescape(utils.path_relative(filename, vim.fn.getcwd())))
336+
fname = vim.fn.fnameescape(utils.path_relative(filename, vim.fn.getcwd()))
337337
else
338-
fname = utils.escape_special_chars(vim.fn.fnameescape(filename))
338+
fname = vim.fn.fnameescape(filename)
339339
end
340340

341341
local command
@@ -372,35 +372,36 @@ end
372372
---@param mode string
373373
---@param filename string
374374
function M.fn(mode, filename)
375+
local fname = utils.escape_special_chars(filename)
375376
if type(mode) ~= "string" then
376377
mode = ""
377378
end
378379

379380
if mode == "tabnew" then
380-
return open_file_in_tab(filename)
381+
return open_file_in_tab(fname)
381382
end
382383

383384
if mode == "drop" then
384-
return drop(filename)
385+
return drop(fname)
385386
end
386387

387388
if mode == "tab_drop" then
388-
return tab_drop(filename)
389+
return tab_drop(fname)
389390
end
390391

391392
if mode == "edit_in_place" then
392-
return edit_in_current_buf(filename)
393+
return edit_in_current_buf(fname)
393394
end
394395

395-
local buf_loaded = is_already_loaded(filename)
396+
local buf_loaded = is_already_loaded(fname)
396397

397398
local found_win = utils.get_win_buf_from_path(filename)
398399
if found_win and (mode == "preview" or mode == "preview_no_picker") then
399400
return
400401
end
401402

402403
if not found_win then
403-
open_in_new_window(filename, mode)
404+
open_in_new_window(fname, mode)
404405
else
405406
vim.api.nvim_set_current_win(found_win)
406407
vim.bo.bufhidden = ""

lua/nvim-tree/utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function M.escape_special_chars(path)
290290
if path == nil then
291291
return path
292292
end
293-
return M.is_windows and path:gsub("%(", "\\("):gsub("%)", "\\)") or path
293+
return M.is_windows and path:gsub("\\", "/") or path
294294
end
295295

296296
--- Create empty sub-tables if not present

lua/nvim-tree/view.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local events = require "nvim-tree.events"
22
local utils = require "nvim-tree.utils"
33
local log = require "nvim-tree.log"
4+
local notify = require "nvim-tree.notify"
45

56
---@class OpenInWinOpts
67
---@field hijack_current_buf boolean|nil default true
@@ -227,7 +228,11 @@ local function close(tabpage)
227228
vim.api.nvim_set_current_win(vim.fn.win_getid(prev_win))
228229
end
229230
if vim.api.nvim_win_is_valid(tree_win or 0) then
230-
vim.api.nvim_win_close(tree_win or 0, true)
231+
local success, error = pcall(vim.api.nvim_win_close, tree_win or 0, true)
232+
if not success then
233+
notify.debug("Failed to close window: " .. error)
234+
return
235+
end
231236
end
232237
events._dispatch_on_tree_close()
233238
return

0 commit comments

Comments
 (0)