Skip to content

Commit f61edfe

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 8701cbe commit f61edfe

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lua/neotest-vstest/init.lua

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,28 +143,28 @@ local function create_adapter(config)
143143
local fullpath = 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.dirname(proj.proj_file)
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
165-
end
166-
return false
152+
:any(function(project_dir)
153+
-- path should be a subdir of a solution project
154+
-- or the solution project should be a subdir of the path
155+
return vim.fs.relpath(project_dir, fullpath) ~= nil
156+
or vim.fs.relpath(fullpath, project_dir) ~= nil
167157
end)
158+
if not is_project_reachable then
159+
logger.debug(
160+
string.format(
161+
"neotest-vstest: file '%s' is not a part of the solution '%s'",
162+
rel_path,
163+
solution_info.solution_file
164+
)
165+
)
166+
end
167+
return is_project_reachable
168168
else
169169
return true
170170
end

0 commit comments

Comments
 (0)