fix: add refresh guard mecanism to avoid doing too many updates

This commit is contained in:
kiyan
2021-07-20 00:05:03 +02:00
parent 07e92cd59b
commit cf9582962f

View File

@@ -165,8 +165,13 @@ local function refresh_nodes(node)
end
end
-- this variable is used to bufferize the refresh actions
-- so only one happens every second at most
local refreshing = false
function M.refresh_tree()
if vim.v.exiting ~= vim.NIL then return end
if refreshing or vim.v.exiting ~= vim.NIL then return end
refreshing = true
refresh_nodes(M.Tree)
@@ -188,6 +193,8 @@ function M.refresh_tree()
else
M.Tree.loaded = false
end
vim.defer_fn(function() refreshing = false end, 1000)
end
function M.set_index_and_redraw(fname)