fix: prevent NvimTree to be alternate buffer when tab open (#3205)
* fix: prevent NvimTree to be alternate buffer when tab open * fix: prevent tabnew leave a dangling "[No Name]" buffer * Update lua/nvim-tree/actions/node/open-file.lua Co-authored-by: Alexander Courtis <alex@courtis.org> --------- Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
parent
87d096a39c
commit
e397756d2a
@ -198,7 +198,15 @@ local function open_file_in_tab(filename)
|
|||||||
if M.relative_path then
|
if M.relative_path then
|
||||||
filename = utils.path_relative(filename, vim.fn.getcwd())
|
filename = utils.path_relative(filename, vim.fn.getcwd())
|
||||||
end
|
end
|
||||||
vim.cmd("tabe " .. vim.fn.fnameescape(filename))
|
vim.cmd.tabnew()
|
||||||
|
vim.bo.bufhidden = "wipe"
|
||||||
|
-- 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)
|
||||||
|
vim.api.nvim_buf_delete(tmpbuf, { force = true })
|
||||||
|
end
|
||||||
|
vim.cmd.edit(vim.fn.fnameescape(filename))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function drop(filename)
|
local function drop(filename)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user