Skip to content

Commit

Permalink
more logging, move raw watch-notifications to DEBUG.
Browse files Browse the repository at this point in the history
  • Loading branch information
L3MON4D3 committed Oct 8, 2023
1 parent 8d8fe03 commit 431cd26
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lua/luasnip/loaders/tree_watcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ function TreeWatcher:new_file(rel, full)
-- already added
return
end

log.info("new file %s %s", rel, full)
self.files[rel] = true
self.callbacks.new_file(full)
end
Expand All @@ -31,6 +33,8 @@ function TreeWatcher:new_dir(rel, full)
-- already added
return
end

log.info("new dir %s %s", rel, full)
-- first do callback for this directory, then look into (and potentially do
-- callbacks for) children.
self.callbacks.new_dir(full)
Expand All @@ -39,21 +43,25 @@ end

function TreeWatcher:change_child(rel, full)
if self.dir_watchers[rel] then
log.info("changed dir %s %s", rel, full)
self.callbacks.change_dir(full)
elseif self.files[rel] then
log.info("changed file %s %s", rel, full)
self.callbacks.change_file(full)
end
end

function TreeWatcher:remove_child(rel, full)
if self.dir_watchers[rel] then
log.info("removing dir %s %s", rel, full)
-- should have been stopped by the watcher for the child, or it was not
-- even started due to depth.
self.dir_watchers[rel]:remove_root()
self.dir_watchers[rel] = nil

self.callbacks.remove_dir(full)
elseif self.files[rel] then
log.info("removing file %s %s", rel, full)
self.files[rel] = nil

self.callbacks.remove_file(full)
Expand All @@ -65,6 +73,7 @@ function TreeWatcher:remove_root()
-- already removed
return
end
log.info("removing root %s", self.root)
self.removed = true
-- stop own, children should have handled themselves, if they are watched.
self.fs_event:stop()
Expand Down Expand Up @@ -112,7 +121,7 @@ function M.new(root, depth, callbacks)
return
end
vim.schedule_wrap(function()
log.info("raw: root: %s; err: %s; relpath: %s; change: %s; rename: %s", o.root, err, relpath, events.change, events.rename)
log.debug("raw: root: %s; err: %s; relpath: %s; change: %s; rename: %s", o.root, err, relpath, events.change, events.rename)
local full_path = Path.join(root, relpath)
local path_stat = uv.fs_stat(full_path)

Expand Down

0 comments on commit 431cd26

Please sign in to comment.