perf: modified takes a long time when refreshing
bugawaiting feedbackreproduced
### 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:
https://github.com/nvim-tree/nvim-tree.lua/blob/c988e289428d9202b28ba27479647033c7dd2956/lua/nvim-tree/explorer/init.lua#L185-L193
The `refresh_nodes` takes a long time in sync mode:
https://github.com/nvim-tree/nvim-tree.lua/blob/c988e289428d9202b28ba27479647033c7dd2956/lua/nvim-tree/explorer/init.lua#L471-L484
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
```text
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
e11ce83ed9a00f065bf676ae4e6c261c766989ba
### Clean room replication
```lua
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:
1. Use `nvim -u repro.lua` to start up nvim in a directories with about 20,000 files
2. Open nvim tree, and expand the directory with many files:
<img width="1788" height="1993" alt="Image" src="https://github.com/user-attachments/assets/9254d52f-98bd-4e90-a1cf-dbcce3c2153b" />
3. Open a file and start to edit it. (Or a floating window like telescope pickers)
### Expected behavior
_No response_
### Actual behavior
_No response_
5 条评论