fix: do not redraw git on each folder when updating
This commit is contained in:
@@ -103,7 +103,7 @@ function M.git_root(path)
|
|||||||
return git_root
|
return git_root
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.update_status(entries, cwd, parent_node)
|
function M.update_status(entries, cwd, parent_node, with_redraw)
|
||||||
local git_root, git_status = get_git_root(cwd)
|
local git_root, git_status = get_git_root(cwd)
|
||||||
if not git_root then
|
if not git_root then
|
||||||
if not create_root(cwd) then
|
if not create_root(cwd) then
|
||||||
@@ -148,7 +148,9 @@ function M.update_status(entries, cwd, parent_node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if with_redraw then
|
||||||
require'nvim-tree.lib'.redraw()
|
require'nvim-tree.lib'.redraw()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Check if the given path is ignored by git.
|
---Check if the given path is ignored by git.
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ end
|
|||||||
|
|
||||||
local function refresh_git(node)
|
local function refresh_git(node)
|
||||||
if not node then node = M.Tree end
|
if not node then node = M.Tree end
|
||||||
git.update_status(node.entries, node.absolute_path or node.cwd, node)
|
git.update_status(node.entries, node.absolute_path or node.cwd, node, false)
|
||||||
for _, entry in pairs(node.entries) do
|
for _, entry in pairs(node.entries) do
|
||||||
if entry.entries and #entry.entries > 0 then
|
if entry.entries and #entry.entries > 0 then
|
||||||
refresh_git(entry)
|
refresh_git(entry)
|
||||||
@@ -175,6 +175,7 @@ function M.refresh_tree()
|
|||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
git.reload_roots()
|
git.reload_roots()
|
||||||
refresh_git(M.Tree)
|
refresh_git(M.Tree)
|
||||||
|
M.redraw()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ function M.populate(entries, cwd, parent_node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if config.use_git() then
|
if config.use_git() then
|
||||||
vim.schedule(function() git.update_status(entries, cwd, parent_node) end)
|
vim.schedule(function() git.update_status(entries, cwd, parent_node, true) end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user