Skip to content

Commit 26dd7db

Browse files
committed
fix: prevent NvimTree to be alternate buffer when tab open
1 parent 87d096a commit 26dd7db

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,14 @@ local function open_file_in_tab(filename)
198198
if M.relative_path then
199199
filename = utils.path_relative(filename, vim.fn.getcwd())
200200
end
201-
vim.cmd("tabe " .. vim.fn.fnameescape(filename))
201+
vim.cmd.tabnew()
202+
-- HACK: prevent NvimTree to be alternate buffer
203+
if utils.is_nvim_tree_buf(vim.fn.bufnr("#")) then
204+
local tmpbuf = vim.api.nvim_create_buf(false, true)
205+
vim.fn.setreg("#", tmpbuf)
206+
vim.api.nvim_buf_delete(tmpbuf, { force = true })
207+
end
208+
vim.cmd.edit(vim.fn.fnameescape(filename))
202209
end
203210

204211
local function drop(filename)

0 commit comments

Comments
 (0)