Skip to content

Commit

Permalink
fix: no autocommand file name to substitute for <afile> (#416)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Arcangeli <[email protected]>
  • Loading branch information
stevearc and stevearc-stripe authored Jun 9, 2024
1 parent 02eb256 commit 2149a76
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lua/neotest/client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ function neotest.Client:_start(args)
})
end

autocmd({ "BufAdd", "BufWritePost" }, function()
local file_path = vim.fn.expand("<afile>:p")
autocmd({ "BufAdd", "BufWritePost" }, function(ev)
local file_path = vim.fn.fnamemodify(ev.file, ":p")

if not lib.files.exists(file_path) then
return
Expand Down Expand Up @@ -446,8 +446,8 @@ function neotest.Client:_start(args)
end)
end)

autocmd({ "BufAdd", "BufDelete" }, function()
local updated_dir = vim.fn.expand("<afile>:p:h")
autocmd({ "BufAdd", "BufDelete" }, function(ev)
local updated_dir = vim.fn.fnamemodify(ev.file, ":p:h")
nio.run(function()
local adapter_id = self:_get_adapter(updated_dir, nil)
if not adapter_id then
Expand All @@ -460,8 +460,8 @@ function neotest.Client:_start(args)
end)
end)

autocmd("BufEnter", function()
local path = vim.fn.expand("<afile>:p")
autocmd("BufEnter", function(ev)
local path = vim.fn.fnamemodify(ev.file, ":p")

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

autocmd({ "CursorHold", "BufEnter" }, function()
local path, line = vim.fn.expand("<afile>:p"), vim.fn.line(".")
local path, line = vim.fn.expand("%:p"), vim.fn.line(".")

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

0 comments on commit 2149a76

Please sign in to comment.