diff --git a/lua/nvim-tree/fs.lua b/lua/nvim-tree/fs.lua index 54b52185..152779e1 100644 --- a/lua/nvim-tree/fs.lua +++ b/lua/nvim-tree/fs.lua @@ -38,7 +38,7 @@ local function create_file(file) luv.fs_chmod(file, 420) luv.fs_close(fd) events._dispatch_file_created(file) - lib.refresh_tree() + lib.refresh_tree(true) focus_file(file) end end)) @@ -99,7 +99,7 @@ function M.create(node) if idx == num_entries then events._dispatch_folder_created(abs_path) api.nvim_out_write('Folder '..abs_path..' was properly created\n') - lib.refresh_tree() + lib.refresh_tree(true) end else create_file(abs_path) @@ -237,7 +237,7 @@ local function do_paste(node, action_type, action_fn) end clipboard[action_type] = {} - return lib.refresh_tree() + return lib.refresh_tree(true) end local function add_to_clipboard(node, clip) @@ -274,7 +274,7 @@ function M.remove(node) events._dispatch_file_removed(node.absolute_path) clear_buffer(node.absolute_path) end - lib.refresh_tree() + lib.refresh_tree(true) end end @@ -296,7 +296,7 @@ function M.rename(with_sub) api.nvim_out_write(node.absolute_path..' ➜ '..new_name..'\n') rename_loaded_buffers(node.absolute_path, new_name) events._dispatch_node_renamed(abs_path, new_name) - lib.refresh_tree() + lib.refresh_tree(true) end end diff --git a/lua/nvim-tree/lib.lua b/lua/nvim-tree/lib.lua index b39ee67f..40982c14 100644 --- a/lua/nvim-tree/lib.lua +++ b/lua/nvim-tree/lib.lua @@ -174,8 +174,8 @@ end -- so only one happens every second at most local refreshing = false -function M.refresh_tree() - if refreshing or vim.v.exiting ~= vim.NIL then return end +function M.refresh_tree(disable_clock) + if (not disable_clock and refreshing) or vim.v.exiting ~= vim.NIL then return end refreshing = true refresh_nodes(M.Tree) @@ -199,7 +199,9 @@ function M.refresh_tree() M.Tree.loaded = false end - vim.defer_fn(function() refreshing = false end, 1000) + if not disable_clock then + vim.defer_fn(function() refreshing = false end, 1000) + end end function M.set_index_and_redraw(fname)