Skip to content

Commit 2c5a3cc

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 2c5a3cc

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

lua/neotest-vstest/init.lua

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,28 +143,27 @@ 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) or vim.fs.relpath(fullpath, project_dir)
167156
end)
157+
if not is_project_reachable then
158+
logger.debug(
159+
string.format(
160+
"neotest-vstest: file '%s' is not a part of the solution '%s'",
161+
rel_path,
162+
solution_info.solution_file
163+
)
164+
)
165+
end
166+
return is_project_reachable
168167
else
169168
return true
170169
end

0 commit comments

Comments
 (0)