Skip to content

Commit b21f13d

Browse files
committed
fix(dir-filter): look for first parent project
In order to see if the directory should be scanned we need to check upward for the first project (assuming that no file can be contained within two or more projects at the same time). Furthermore Ive changed some variable names and added a log if the directory is ignored because it is determined not to be from the solution project.
1 parent dc77b30 commit b21f13d

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

lua/neotest-vstest/init.lua

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,31 +140,33 @@ local function create_adapter(config)
140140
end
141141

142142
-- Filter out directories that are not part of the solution (if there is a solution)
143-
local fullpath = vim.fs.joinpath(root, rel_path)
143+
local fullpath = vim.fs.normalize(vim.fs.joinpath(root, rel_path))
144144
if solution_dir then
145145
local solution_info = dotnet_utils.get_solution_info(solution)
146-
local project_files = vim.fs.find(function(path, _)
147-
return path:match("%.[cf]sproj$")
148-
end, {
149-
upward = false,
150-
type = "file",
151-
path = fullpath,
152-
limit = math.huge,
153-
})
154146

155-
return vim
147+
local is_project_reachable = vim
156148
.iter(solution_info and solution_info.projects or {})
157149
:map(function(proj)
158-
return proj.proj_file
150+
return vim.fs.normalize(vim.fn.fnamemodify(proj.proj_file, ":p:h"))
159151
end)
160-
:any(function(proj_file)
161-
for _, file in ipairs(project_files) do
162-
if vim.fs.normalize(proj_file) == vim.fs.normalize(file) then
163-
return true
164-
end
152+
:any(function(sln_project_file)
153+
if
154+
fullpath:find(sln_project_file, 1, true) or sln_project_file:find(fullpath, 1, true)
155+
then
156+
return true
165157
end
166158
return false
167159
end)
160+
if not is_project_reachable then
161+
logger.debug(
162+
string.format(
163+
"neotest-vstest: file '%s' is not a part of the solution '%s'",
164+
rel_path,
165+
solution_info.solution_file
166+
)
167+
)
168+
end
169+
return is_project_reachable
168170
else
169171
return true
170172
end

0 commit comments

Comments
 (0)