fix: fs refresh override refresh clock
This commit is contained in:
@@ -38,7 +38,7 @@ local function create_file(file)
|
|||||||
luv.fs_chmod(file, 420)
|
luv.fs_chmod(file, 420)
|
||||||
luv.fs_close(fd)
|
luv.fs_close(fd)
|
||||||
events._dispatch_file_created(file)
|
events._dispatch_file_created(file)
|
||||||
lib.refresh_tree()
|
lib.refresh_tree(true)
|
||||||
focus_file(file)
|
focus_file(file)
|
||||||
end
|
end
|
||||||
end))
|
end))
|
||||||
@@ -99,7 +99,7 @@ function M.create(node)
|
|||||||
if idx == num_entries then
|
if idx == num_entries then
|
||||||
events._dispatch_folder_created(abs_path)
|
events._dispatch_folder_created(abs_path)
|
||||||
api.nvim_out_write('Folder '..abs_path..' was properly created\n')
|
api.nvim_out_write('Folder '..abs_path..' was properly created\n')
|
||||||
lib.refresh_tree()
|
lib.refresh_tree(true)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
create_file(abs_path)
|
create_file(abs_path)
|
||||||
@@ -237,7 +237,7 @@ local function do_paste(node, action_type, action_fn)
|
|||||||
end
|
end
|
||||||
|
|
||||||
clipboard[action_type] = {}
|
clipboard[action_type] = {}
|
||||||
return lib.refresh_tree()
|
return lib.refresh_tree(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_to_clipboard(node, clip)
|
local function add_to_clipboard(node, clip)
|
||||||
@@ -274,7 +274,7 @@ function M.remove(node)
|
|||||||
events._dispatch_file_removed(node.absolute_path)
|
events._dispatch_file_removed(node.absolute_path)
|
||||||
clear_buffer(node.absolute_path)
|
clear_buffer(node.absolute_path)
|
||||||
end
|
end
|
||||||
lib.refresh_tree()
|
lib.refresh_tree(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@ function M.rename(with_sub)
|
|||||||
api.nvim_out_write(node.absolute_path..' ➜ '..new_name..'\n')
|
api.nvim_out_write(node.absolute_path..' ➜ '..new_name..'\n')
|
||||||
rename_loaded_buffers(node.absolute_path, new_name)
|
rename_loaded_buffers(node.absolute_path, new_name)
|
||||||
events._dispatch_node_renamed(abs_path, new_name)
|
events._dispatch_node_renamed(abs_path, new_name)
|
||||||
lib.refresh_tree()
|
lib.refresh_tree(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -174,8 +174,8 @@ end
|
|||||||
-- so only one happens every second at most
|
-- so only one happens every second at most
|
||||||
local refreshing = false
|
local refreshing = false
|
||||||
|
|
||||||
function M.refresh_tree()
|
function M.refresh_tree(disable_clock)
|
||||||
if refreshing or vim.v.exiting ~= vim.NIL then return end
|
if (not disable_clock and refreshing) or vim.v.exiting ~= vim.NIL then return end
|
||||||
refreshing = true
|
refreshing = true
|
||||||
|
|
||||||
refresh_nodes(M.Tree)
|
refresh_nodes(M.Tree)
|
||||||
@@ -199,7 +199,9 @@ function M.refresh_tree()
|
|||||||
M.Tree.loaded = false
|
M.Tree.loaded = false
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.defer_fn(function() refreshing = false end, 1000)
|
if not disable_clock then
|
||||||
|
vim.defer_fn(function() refreshing = false end, 1000)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.set_index_and_redraw(fname)
|
function M.set_index_and_redraw(fname)
|
||||||
|
|||||||
Reference in New Issue
Block a user