* fix(#1720): .git watch only HEAD, config and index * fix(#1720): .git watch only FETCH_HEAD, HEAD, HEAD.lock, config, index
This commit is contained in:
committed by
GitHub
parent
7e892767bd
commit
bcb2a5a80d
@@ -58,7 +58,7 @@ function Event:start()
|
||||
else
|
||||
log.line("watcher", "event_cb '%s' '%s'", self._path, filename)
|
||||
for _, listener in ipairs(self._listeners) do
|
||||
listener()
|
||||
listener(filename)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -101,14 +101,15 @@ function Event:destroy(message)
|
||||
Event._events[self._path] = nil
|
||||
end
|
||||
|
||||
function Watcher:new(path, callback, data)
|
||||
log.line("watcher", "Watcher:new '%s'", path)
|
||||
function Watcher:new(path, files, callback, data)
|
||||
log.line("watcher", "Watcher:new '%s' %s", path, vim.inspect(files))
|
||||
|
||||
local w = setmetatable(data, Watcher)
|
||||
|
||||
w._event = Event._events[path] or Event:new(path)
|
||||
w._listener = nil
|
||||
w._path = path
|
||||
w._files = files
|
||||
w._callback = callback
|
||||
|
||||
if not w._event then
|
||||
@@ -123,8 +124,10 @@ function Watcher:new(path, callback, data)
|
||||
end
|
||||
|
||||
function Watcher:start()
|
||||
self._listener = function()
|
||||
self._callback(self)
|
||||
self._listener = function(filename)
|
||||
if not self._files or vim.tbl_contains(self._files, filename) then
|
||||
self._callback(self)
|
||||
end
|
||||
end
|
||||
|
||||
self._event:add(self._listener)
|
||||
|
||||
Reference in New Issue
Block a user