Skip to content

Commit

Permalink
fix: ignore unnamed buffers on autocmd (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
hori-ryota authored Sep 22, 2024
1 parent 6d6ad11 commit 9917051
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lua/neotest/client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ function neotest.Client:_start(args)
end

autocmd({ "BufAdd", "BufWritePost" }, function(ev)
if ev.file == "" then
return
end

local file_path = vim.fn.fnamemodify(ev.file, ":p")

if not lib.files.exists(file_path) then
Expand Down Expand Up @@ -447,6 +451,9 @@ function neotest.Client:_start(args)
end)

autocmd({ "BufAdd", "BufDelete" }, function(ev)
if ev.file == "" then
return
end
local updated_dir = vim.fn.fnamemodify(ev.file, ":p:h")
nio.run(function()
local adapter_id = self:_get_adapter(updated_dir, nil)
Expand All @@ -461,6 +468,9 @@ function neotest.Client:_start(args)
end)

autocmd("BufEnter", function(ev)
if ev.file == "" then
return
end
local path = vim.fn.fnamemodify(ev.file, ":p")

if not lib.files.exists(path) then
Expand All @@ -473,6 +483,9 @@ function neotest.Client:_start(args)
end)

autocmd({ "CursorHold", "BufEnter" }, function()
if vim.fn.expand("%") == "" then
return
end
local path, line = vim.fn.expand("%:p"), vim.fn.line(".")

if not lib.files.exists(path) then
Expand Down

0 comments on commit 9917051

Please sign in to comment.