Skip to content

Commit 2f5ad84

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

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

lua/neotest-vstest/init.lua

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,31 +140,32 @@ 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(project_dir)
153+
-- path should be a subdir of a solution project or the solution project should be a subdir of the path
154+
if fullpath:find(project_dir, 1, true) or project_dir:find(fullpath, 1, true) then
155+
return true
165156
end
166157
return false
167158
end)
159+
if not is_project_reachable then
160+
logger.debug(
161+
string.format(
162+
"neotest-vstest: file '%s' is not a part of the solution '%s'",
163+
rel_path,
164+
solution_info.solution_file
165+
)
166+
)
167+
end
168+
return is_project_reachable
168169
else
169170
return true
170171
end

0 commit comments

Comments
 (0)