fix(#1804): do not refresh watched nodes that have been destroyed (deleted)
This commit is contained in:
parent
e0cfbbb93d
commit
d949af7245
@ -121,6 +121,7 @@ function M.node_destroy(node)
|
||||
|
||||
if node.watcher then
|
||||
node.watcher:destroy()
|
||||
node.watcher = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -51,6 +51,9 @@ function M.create_watcher(node)
|
||||
local function callback(watcher)
|
||||
log.line("watcher", "node event scheduled refresh %s", watcher.context)
|
||||
utils.debounce(watcher.context, M.debounce_delay, function()
|
||||
if watcher.destroyed then
|
||||
return
|
||||
end
|
||||
if node.link_to then
|
||||
log.line("watcher", "node event executing refresh '%s' -> '%s'", node.link_to, node.absolute_path)
|
||||
else
|
||||
|
||||
@ -150,6 +150,9 @@ function M.load_project_status(cwd)
|
||||
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()
|
||||
if w.destroyed then
|
||||
return
|
||||
end
|
||||
reload_tree_at(w.project_root)
|
||||
end)
|
||||
end
|
||||
|
||||
@ -99,6 +99,8 @@ function Event:destroy(message)
|
||||
end
|
||||
|
||||
Event._events[self._path] = nil
|
||||
|
||||
self.destroyed = true
|
||||
end
|
||||
|
||||
function Watcher:new(path, files, callback, data)
|
||||
@ -139,6 +141,8 @@ function Watcher:destroy()
|
||||
self._event:remove(self._listener)
|
||||
|
||||
utils.array_remove(Watcher._watchers, self)
|
||||
|
||||
self.destroyed = true
|
||||
end
|
||||
|
||||
M.Watcher = Watcher
|
||||
|
||||
Loading…
Reference in New Issue
Block a user