fix(lua): don't leak handle when vim._watch.watch() fails (#35768)

This fixes the following warning in tests with ASAN or TSAN:

    -------- Running tests from test/functional/lua/watch_spec.lua
    RUN      T4253 vim._watch watch() ignores nonexistent paths: 29.00 ms OK
    nvim took 2006 milliseconds to exit after last test
    This indicates a likely problem with the test even if it passed!
This commit is contained in:
zeertzjq
2025-09-15 11:15:25 +08:00
parent 14e74d98fd
commit 7b1ac2080d
2 changed files with 2 additions and 1 deletions

View File

@@ -102,6 +102,7 @@ function M.watch(path, opts, callback)
-- This is mostly a placeholder until we have `nvim_log` API.
vim.notify_once(('watch.watch: %s'):format(start_err), vim.log.levels.INFO)
end
handle:close()
-- TODO(justinmk): log important errors once we have `nvim_log` API.
return function() end
end