Skip to content

Commit

Permalink
fix(status): filter unlisted bufs
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarriga committed Sep 13, 2022
1 parent c6359d7 commit 15c0bb2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
7 changes: 2 additions & 5 deletions lua/neotest/client/events/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ function NeotestEventProcessor:emit(event, ...)
async.run(function()
logger.info("Emitting", event, "event")
for name, listener in pairs(self.listeners[event] or {}) do
logger.debug("Calling listener", name, "for event", event)
local success, err = pcall(listener, unpack(args))
if not success then
logger.error("Error during listener", name, "for event:", err)
end
logger.info("Calling listener", name, "for event", event)
listener(unpack(args))
end
end)
end
Expand Down
2 changes: 1 addition & 1 deletion lua/neotest/consumers/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ local function init(client)
local function draw_buffer(path, adapter_id)
if not buf_diags[path] then
local bufnr = async.fn.bufnr(path)
if bufnr == -1 then
if bufnr == -1 or async.fn.buflisted(bufnr) == 0 then
return
end
if not client:get_results(adapter_id)[path] then
Expand Down
24 changes: 13 additions & 11 deletions lua/neotest/consumers/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,26 @@ local function init(client)

local function render_files(adapter_id, files)
for _, file_path in pairs(files) do
local results = client:get_results(adapter_id)
async.fn.sign_unplace(sign_group, { buffer = file_path })
async.api.nvim_buf_clear_namespace(async.fn.bufnr(file_path), namespace, 0, -1)
local tree = client:get_position(file_path, { adapter = adapter_id })
if not tree then
return
end
for _, pos in tree:iter() do
if pos.type ~= "file" then
place_sign(async.fn.bufnr(file_path), pos, adapter_id, results)
if async.fn.buflisted(async.fn.bufnr(file_path)) ~= 0 then
local results = client:get_results(adapter_id)
async.fn.sign_unplace(sign_group, { buffer = file_path })
async.api.nvim_buf_clear_namespace(async.fn.bufnr(file_path), namespace, 0, -1)
local tree = client:get_position(file_path, { adapter = adapter_id })
if not tree then
return
end
for _, pos in tree:iter() do
if pos.type ~= "file" then
place_sign(async.fn.bufnr(file_path), pos, adapter_id, results)
end
end
end
end
end

client.listeners.discover_positions = function(adapter_id, tree)
local file_path = tree:data().id
if tree:data().type == "file" and async.fn.bufnr(file_path) ~= -1 then
if tree:data().type == "file" then
render_files(adapter_id, { file_path })
end
end
Expand Down

0 comments on commit 15c0bb2

Please sign in to comment.