chore(watchers): Watcher shares single fs_event from Event, node watchers use unique path prefixed debounce context (#1453)

This commit is contained in:
Alexander Courtis
2022-07-26 18:43:58 +10:00
committed by GitHub
parent e5222970d9
commit eff1db341c
4 changed files with 156 additions and 84 deletions

View File

@@ -143,16 +143,17 @@ function M.load_project_status(cwd)
local watcher = nil
if M.config.filesystem_watchers.enable then
log.line("watcher", "git start")
watcher = Watcher.new {
absolute_path = utils.path_join { project_root, ".git" },
local callback = function(w)
log.line("watcher", "git event scheduled '%s'", w.project_root)
utils.debounce("git:watcher:" .. w.project_root, M.config.filesystem_watchers.debounce_delay, function()
reload_tree_at(w.project_root)
end)
end
watcher = Watcher:new(utils.path_join { project_root, ".git" }, callback, {
project_root = project_root,
on_event = function(opts)
log.line("watcher", "git event scheduled '%s'", opts.project_root)
utils.debounce("git:watcher:" .. opts.project_root, M.config.filesystem_watchers.debounce_delay, function()
reload_tree_at(opts.project_root)
end)
end,
}
})
end
M.projects[project_root] = {