Description
When a folder with many files is expanded and the modified feature is on, editing in buffers will suffer a significant lag.
Log files:
https://github.com/Kaiser-Yang/image-hosting-site/blob/main/nvim-tree.log
I've found that this is caused by:
|
vim.api.nvim_create_autocmd({ "BufModifiedSet", "BufWritePost" }, { |
|
group = self.augroup_id, |
|
callback = function() |
|
utils.debounce("Buf:modified_" .. self.uid_explorer, self.opts.view.debounce_delay, function() |
|
buffers.reload_modified() |
|
self:reload_explorer() |
|
end) |
|
end, |
|
}) |
The refresh_nodes takes a long time in sync mode:
|
function Explorer:refresh_nodes(projects) |
|
Iterator.builder({ self }) |
|
:applier(function(n) |
|
local dir = n:as(DirectoryNode) |
|
if dir then |
|
local toplevel = git.get_toplevel(dir.cwd or dir.link_to or dir.absolute_path) |
|
self:reload(dir, projects[toplevel] or {}) |
|
end |
|
end) |
|
:recursor(function(n) |
|
return n.group_next and { n.group_next } or (n.open and n.nodes) |
|
end) |
|
:iterate() |
|
end |
But I think iterating about 20000 nodes should not be so slow.
The workaround for this problem is just to disable the modified feature.
Neovim version
NVIM v0.11.4
Build type: RelWithDebInfo
LuaJIT 2.1.1753364724
Run "nvim -V1 -v" for more info
Operating system and version
Linux archlinux 6.16.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 02 Oct 2025 19:26:36 +0000 x86_64 GNU/Linux
Windows variant
No response
nvim-tree version
e11ce83
Clean room replication
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvt-min/site]])
local package_root = '/tmp/nvt-min/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
require('packer').startup({
{
'wbthomason/packer.nvim',
'nvim-tree/nvim-tree.lua',
'nvim-tree/nvim-web-devicons',
-- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
},
config = {
package_root = package_root,
compile_path = install_path .. '/plugin/packer_compiled.lua',
display = { non_interactive = true },
},
})
end
if vim.fn.isdirectory(install_path) == 0 then
print('Installing nvim-tree and dependencies.')
vim.fn.system({ 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path })
end
load_plugins()
require('packer').sync()
vim.cmd([[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]])
vim.opt.termguicolors = true
vim.opt.cursorline = true
-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
require('nvim-tree').setup({
-- Enable modified
modified = { enable = true },
})
end
Steps to reproduce
Steps to repro:
- Use
nvim -u repro.lua to start up nvim in a directories with about 20,000 files
- Open nvim tree, and expand the directory with many files:
- Open a file and start to edit it. (Or a floating window like telescope pickers)
Expected behavior
No response
Actual behavior
No response
Description
When a folder with many files is expanded and the
modifiedfeature is on, editing in buffers will suffer a significant lag.Log files:
https://github.com/Kaiser-Yang/image-hosting-site/blob/main/nvim-tree.log
I've found that this is caused by:
nvim-tree.lua/lua/nvim-tree/explorer/init.lua
Lines 185 to 193 in c988e28
The
refresh_nodestakes a long time in sync mode:nvim-tree.lua/lua/nvim-tree/explorer/init.lua
Lines 471 to 484 in c988e28
But I think iterating about 20000 nodes should not be so slow.
The workaround for this problem is just to disable the modified feature.
Neovim version
Operating system and version
Linux archlinux 6.16.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 02 Oct 2025 19:26:36 +0000 x86_64 GNU/Linux
Windows variant
No response
nvim-tree version
e11ce83
Clean room replication
Steps to reproduce
Steps to repro:
nvim -u repro.luato start up nvim in a directories with about 20,000 filesExpected behavior
No response
Actual behavior
No response