diff --git a/lua/lint.lua b/lua/lint.lua index 0acf8bbb..d1e7794b 100644 --- a/lua/lint.lua +++ b/lua/lint.lua @@ -116,12 +116,10 @@ function LintProc:publish(diagnostics) if api.nvim_buf_is_valid(self.bufnr) and not self.cancelled then vim.diagnostic.set(self.ns, self.bufnr, diagnostics) end - self.stdout:shutdown(function() - self.stdout:close() - end) - self.stderr:shutdown(function() - self.stderr:close() - end) + self.stdout:shutdown() + self.stdout:close() + self.stderr:shutdown() + self.stderr:close() end diff --git a/tests/compiler_spec.lua b/tests/compiler_spec.lua index 2bbc3307..f3ff90aa 100644 --- a/tests/compiler_spec.lua +++ b/tests/compiler_spec.lua @@ -1,3 +1,10 @@ +local function get_num_handles() + local pid = vim.fn.getpid() + local output = vim.fn.system({"lsof", "-p"}, tostring(pid)) + local lines = vim.split(output, "\n", { plain = true }) + return #lines +end + describe('compiler', function() it('reads errors from both stdout and stderr', function() local a = vim.api @@ -6,9 +13,13 @@ describe('compiler', function() a.nvim_buf_set_option(bufnr, 'errorformat', '%l: %m') a.nvim_buf_set_option(bufnr, 'makeprg', 'python tests/both.py') + local handles = get_num_handles() require('lint').try_lint('compiler') vim.wait(5000, function() return next(vim.diagnostic.get(bufnr)) ~= nil end) + + assert.are.same(handles, get_num_handles(), "shouldn't leak any handles") + local result = vim.diagnostic.get(bufnr) for _, d in pairs(result) do d.namespace = nil