Skip to content

Commit 4dff20d

Browse files
nsi-incoNsidorenco
andauthored
fix: project filter searches beyond root dir (#31)
* fix: project filter searches beyond root dir * simplify --------- Co-authored-by: nsidorenco <[email protected]>
1 parent 2e10471 commit 4dff20d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lua/neotest-vstest/init.lua

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,25 @@ local function create_adapter(config)
132132
return false
133133
end
134134

135+
local project_dir
136+
135137
-- Filter out directories that are not part of the solution (if there is a solution)
136138
local fullpath = vim.fs.joinpath(root, rel_path)
137-
local project_dir = vim.fs.root(fullpath, function(path, _)
138-
return path:match("%.[cf]sproj$")
139-
end)
139+
for dir in vim.fs.parents(fullpath) do
140+
if solution_dir then
141+
break
142+
end
143+
144+
for filename in vim.fs.dir(dir) do
145+
if filename:match("%.[cf]sproj$") then
146+
project_dir = dir
147+
break
148+
end
149+
end
150+
if vim.fs.normalize(dir) == vim.fs.normalize(root) then
151+
break
152+
end
153+
end
140154

141155
-- We cannot determine if the file is a test file without a project directory.
142156
-- Keep searching the child by not filtering it out

0 commit comments

Comments
 (0)