Skip to content

Commit 42b2324

Browse files
committed
fix: do not redraw git on each folder when updating
1 parent f178c8c commit 42b2324

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lua/nvim-tree/git.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function M.git_root(path)
103103
return git_root
104104
end
105105

106-
function M.update_status(entries, cwd, parent_node)
106+
function M.update_status(entries, cwd, parent_node, with_redraw)
107107
local git_root, git_status = get_git_root(cwd)
108108
if not git_root then
109109
if not create_root(cwd) then
@@ -148,7 +148,9 @@ function M.update_status(entries, cwd, parent_node)
148148
end
149149
end
150150
end
151-
require'nvim-tree.lib'.redraw()
151+
if with_redraw then
152+
require'nvim-tree.lib'.redraw()
153+
end
152154
end
153155

154156
---Check if the given path is ignored by git.

lua/nvim-tree/lib.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ end
147147

148148
local function refresh_git(node)
149149
if not node then node = M.Tree end
150-
git.update_status(node.entries, node.absolute_path or node.cwd, node)
150+
git.update_status(node.entries, node.absolute_path or node.cwd, node, false)
151151
for _, entry in pairs(node.entries) do
152152
if entry.entries and #entry.entries > 0 then
153153
refresh_git(entry)
@@ -175,6 +175,7 @@ function M.refresh_tree()
175175
vim.schedule(function()
176176
git.reload_roots()
177177
refresh_git(M.Tree)
178+
M.redraw()
178179
end)
179180
end
180181

lua/nvim-tree/populate.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ function M.populate(entries, cwd, parent_node)
355355
end
356356

357357
if config.use_git() then
358-
vim.schedule(function() git.update_status(entries, cwd, parent_node) end)
358+
vim.schedule(function() git.update_status(entries, cwd, parent_node, true) end)
359359
end
360360
end
361361

0 commit comments

Comments
 (0)