From ba4dac1e5904ddf91f3993bb9119d0487cb16a1d Mon Sep 17 00:00:00 2001 From: kiyan Date: Fri, 27 Nov 2020 22:03:27 +0100 Subject: [PATCH] wrap refresh logic in vim.schedule callback --- lua/lib/lib.lua | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lua/lib/lib.lua b/lua/lib/lib.lua index a53df524..0fc32895 100644 --- a/lua/lib/lib.lua +++ b/lua/lib/lib.lua @@ -118,19 +118,22 @@ local function refresh_nodes(node) end function M.refresh_tree() - -- local stat = luv.fs_stat(M.Tree.cwd) - -- if stat.mtime.sec ~= M.Tree.last_modified then - refresh_nodes(M.Tree) - -- end - if config.get_icon_state().show_git_icon or vim.g.lua_tree_git_hl then - git.reload_roots() - refresh_git(M.Tree) - end - if M.win_open() then - renderer.draw(M.Tree, true) - else - M.Tree.loaded = false - end + vim.schedule( + function () + -- local stat = luv.fs_stat(M.Tree.cwd) + -- if stat.mtime.sec ~= M.Tree.last_modified then + refresh_nodes(M.Tree) + -- end + if config.get_icon_state().show_git_icon or vim.g.lua_tree_git_hl then + git.reload_roots() + refresh_git(M.Tree) + end + if M.win_open() then + renderer.draw(M.Tree, true) + else + M.Tree.loaded = false + end + end) end function M.set_index_and_redraw(fname)