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

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
phanium 2025-10-07 09:40:08 +08:00 committed by GitHub
parent e922baab5e
commit edf6ef5e86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -200,7 +200,7 @@ local function open_file_in_tab(filename)
end
vim.cmd.tabnew()
vim.bo.bufhidden = "wipe"
-- HACK: prevent NvimTree to be alternate buffer
-- Following vim.fn.tabnew the # buffer may be set to the tree buffer. There is no way to clear the # buffer via vim.fn.setreg as it requires a valid buffer. Clear # by setting it to a new temporary scratch buffer.
if utils.is_nvim_tree_buf(vim.fn.bufnr("#")) then
local tmpbuf = vim.api.nvim_create_buf(false, true)
vim.fn.setreg("#", tmpbuf)