Skip to content

revert(#3180, #3177): resolve live filter failures #3183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ Following is the default configuration. See |nvim-tree-opts| for details. >lua
},
},
experimental = {
multi_instance = false,
},
log = {
enable = false,
Expand Down
47 changes: 37 additions & 10 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local log = require("nvim-tree.log")
local view = require("nvim-tree.view")
local utils = require("nvim-tree.utils")
local actions = require("nvim-tree.actions")
local core = require("nvim-tree.core")
Expand Down Expand Up @@ -73,8 +74,7 @@ function M.change_root(path, bufnr)
end

function M.tab_enter()
local explorer = core.get_explorer()
if explorer and explorer.view:is_visible({ any_tabpage = true }) then
if view.is_visible({ any_tabpage = true }) then
local bufname = vim.api.nvim_buf_get_name(0)

local ft
Expand All @@ -89,15 +89,17 @@ function M.tab_enter()
return
end
end
explorer.view:open({ focus_tree = false })
view.open({ focus_tree = false })

explorer.renderer:draw()
local explorer = core.get_explorer()
if explorer then
explorer.renderer:draw()
end
end
end

function M.open_on_directory()
local explorer = core.get_explorer()
local should_proceed = _config.hijack_directories.auto_open or explorer and explorer.view:is_visible()
local should_proceed = _config.hijack_directories.auto_open or view.is_visible()
if not should_proceed then
return
end
Expand Down Expand Up @@ -148,6 +150,21 @@ local function setup_autocommands(opts)
vim.api.nvim_create_autocmd(name, vim.tbl_extend("force", default_opts, custom_opts))
end

-- prevent new opened file from opening in the same window as nvim-tree
create_nvim_tree_autocmd("BufWipeout", {
pattern = "NvimTree_*",
callback = function()
if not utils.is_nvim_tree_buf(0) then
return
end
if opts.actions.open_file.eject then
view._prevent_buffer_override()
else
view.abandon_current_window()
end
end,
})

if opts.tab.sync.open then
create_nvim_tree_autocmd("TabEnter", { callback = vim.schedule_wrap(M.tab_enter) })
end
Expand Down Expand Up @@ -209,6 +226,17 @@ local function setup_autocommands(opts)
})
end

if opts.view.float.enable and opts.view.float.quit_on_focus_loss then
create_nvim_tree_autocmd("WinLeave", {
pattern = "NvimTree_*",
callback = function()
if utils.is_nvim_tree_buf(0) then
view.close()
end
end,
})
end

-- Handles event dispatch when tree is closed by `:q`
create_nvim_tree_autocmd("WinClosed", {
pattern = "*",
Expand Down Expand Up @@ -486,7 +514,6 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
},
},
experimental = {
multi_instance = false,
},
log = {
enable = false,
Expand Down Expand Up @@ -666,10 +693,10 @@ local function localise_default_opts()
end

function M.purge_all_state()
view.close_all_tabs()
view.abandon_all_windows()
local explorer = core.get_explorer()
if explorer then
explorer.view:close_all_tabs()
explorer.view:abandon_all_windows("purge_all_state")
require("nvim-tree.git").purge_state()
explorer:destroy()
core.reset_explorer()
Expand Down Expand Up @@ -722,12 +749,12 @@ function M.setup(conf)
require("nvim-tree.explorer.watch").setup(opts)
require("nvim-tree.git").setup(opts)
require("nvim-tree.git.utils").setup(opts)
require("nvim-tree.view").setup(opts)
require("nvim-tree.lib").setup(opts)
require("nvim-tree.renderer.components").setup(opts)
require("nvim-tree.buffers").setup(opts)
require("nvim-tree.help").setup(opts)
require("nvim-tree.watcher").setup(opts)
require("nvim-tree.multi-instance-debug").setup(opts)

setup_autocommands(opts)

Expand Down
7 changes: 4 additions & 3 deletions lua/nvim-tree/actions/finders/find-file.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local log = require("nvim-tree.log")
local view = require("nvim-tree.view")
local utils = require("nvim-tree.utils")
local core = require("nvim-tree.core")

Expand All @@ -13,7 +14,7 @@ local running = {}
---@param path string relative or absolute
function M.fn(path)
local explorer = core.get_explorer()
if not explorer or not explorer.view:is_visible() then
if not explorer or not view.is_visible() then
return
end

Expand Down Expand Up @@ -83,9 +84,9 @@ function M.fn(path)
end)
:iterate()

if found and explorer.view:is_visible() then
if found and view.is_visible() then
explorer.renderer:draw()
explorer.view:set_cursor({ line, 0 })
view.set_cursor({ line, 0 })
end

running[path_real] = false
Expand Down
6 changes: 0 additions & 6 deletions lua/nvim-tree/actions/fs/clipboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ local Clipboard = Class:extend()
---@protected
---@param args ClipboardArgs
function Clipboard:new(args)
args.explorer:log_new("Clipboard")

self.explorer = args.explorer

self.data = {
Expand All @@ -44,10 +42,6 @@ function Clipboard:new(args)
self.reg = self.explorer.opts.actions.use_system_clipboard and "+" or "1"
end

function Clipboard:destroy()
self.explorer:log_destroy("Clipboard")
end

---@param source string
---@param destination string
---@return boolean
Expand Down
10 changes: 4 additions & 6 deletions lua/nvim-tree/actions/fs/remove-file.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local core = require("nvim-tree.core")
local utils = require("nvim-tree.utils")
local events = require("nvim-tree.events")
local view = require("nvim-tree.view")
local lib = require("nvim-tree.lib")
local notify = require("nvim-tree.notify")

Expand All @@ -13,12 +14,10 @@ local M = {

---@param windows integer[]
local function close_windows(windows)
local explorer = core.get_explorer()

-- Prevent from closing when the win count equals 1 or 2,
-- where the win to remove could be the last opened.
-- For details see #2503.
if explorer and explorer.view.float.enable and #vim.api.nvim_list_wins() < 3 then
if view.View.float.enable and #vim.api.nvim_list_wins() < 3 then
return
end

Expand All @@ -31,17 +30,16 @@ end

---@param absolute_path string
local function clear_buffer(absolute_path)
local explorer = core.get_explorer()
local bufs = vim.fn.getbufinfo({ bufloaded = 1, buflisted = 1 })
for _, buf in pairs(bufs) do
if buf.name == absolute_path then
local tree_winnr = vim.api.nvim_get_current_win()
if buf.hidden == 0 and (#bufs > 1 or explorer and explorer.view.float.enable) then
if buf.hidden == 0 and (#bufs > 1 or view.View.float.enable) then
vim.api.nvim_set_current_win(buf.windows[1])
vim.cmd(":bn")
end
vim.api.nvim_buf_delete(buf.bufnr, { force = true })
if explorer and not explorer.view.float.quit_on_focus_loss then
if not view.View.float.quit_on_focus_loss then
vim.api.nvim_set_current_win(tree_winnr)
end
if M.config.actions.remove_file.close_window then
Expand Down
9 changes: 5 additions & 4 deletions lua/nvim-tree/actions/moves/item.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local utils = require("nvim-tree.utils")
local view = require("nvim-tree.view")
local core = require("nvim-tree.core")
local diagnostics = require("nvim-tree.diagnostics")

Expand Down Expand Up @@ -66,9 +67,9 @@ local function move(explorer, where, what, skip_gitignored)
end

if nex then
explorer.view:set_cursor({ nex, 0 })
view.set_cursor({ nex, 0 })
elseif vim.o.wrapscan and first then
explorer.view:set_cursor({ first, 0 })
view.set_cursor({ first, 0 })
end
end

Expand Down Expand Up @@ -188,13 +189,13 @@ local function move_prev_recursive(explorer, what, skip_gitignored)

-- 4.3)
if node_init.name == ".." then -- root node
explorer.view:set_cursor({ 1, 0 }) -- move to root node (position 1)
view.set_cursor({ 1, 0 }) -- move to root node (position 1)
else
local node_init_line = utils.find_node_line(node_init)
if node_init_line < 0 then
return
end
explorer.view:set_cursor({ node_init_line, 0 })
view.set_cursor({ node_init_line, 0 })
end

-- 4.4)
Expand Down
5 changes: 3 additions & 2 deletions lua/nvim-tree/actions/moves/parent.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local view = require("nvim-tree.view")
local utils = require("nvim-tree.utils")

local DirectoryNode = require("nvim-tree.node.directory")
Expand All @@ -24,15 +25,15 @@ function M.fn(should_close)
local parent = (node:get_parent_of_group() or node).parent

if not parent or not parent.parent then
node.explorer.view:set_cursor({ 1, 0 })
view.set_cursor({ 1, 0 })
return
end

local _, line = utils.find_node(parent.explorer.nodes, function(n)
return n.absolute_path == parent.absolute_path
end)

node.explorer.view:set_cursor({ line + 1, 0 })
view.set_cursor({ line + 1, 0 })
if should_close then
parent.open = false
parent.explorer.renderer:draw()
Expand Down
Loading
Loading