@@ -105,6 +105,8 @@ local function create_adapter(config)
105105 local dotnet_utils = require (" neotest-vstest.dotnet_utils" )
106106 local client_discovery = require (" neotest-vstest.client" )
107107
108+ logger .trace (" neotest-vstest: checking if file is test file: " .. file_path )
109+
108110 local isDotnetFile = (vim .endswith (file_path , " .csproj" ) or vim .endswith (file_path , " .fsproj" ))
109111 or (vim .endswith (file_path , " .cs" ) or vim .endswith (file_path , " .fs" ))
110112
@@ -127,50 +129,42 @@ local function create_adapter(config)
127129
128130 function DotnetNeotestAdapter .filter_dir (name , rel_path , root )
129131 local dotnet_utils = require (" neotest-vstest.dotnet_utils" )
132+ local logger = require (" neotest.logging" )
133+ logger .trace (" neotest-vstest: filtering dir" , name , rel_path , root )
130134
131135 if name == " bin" or name == " obj" then
132136 return false
133137 end
134138
135- local project_dir
136-
137139 -- Filter out directories that are not part of the solution (if there is a solution)
138140 local fullpath = vim .fs .joinpath (root , rel_path )
139141 if solution_dir then
140- project_dir = vim .fs .root (fullpath , function (path , _ )
142+ local solution_info = dotnet_utils .get_solution_info (solution )
143+ local project_files = vim .fs .find (function (path , _ )
141144 return path :match (" %.[cf]sproj$" )
142- end )
143- else
144- for dir in vim .fs .parents (fullpath ) do
145- for filename in vim .fs .dir (dir ) do
146- if filename :match (" %.[cf]sproj$" ) then
147- project_dir = dir
148- break
145+ end , {
146+ upward = false ,
147+ type = " file" ,
148+ path = fullpath ,
149+ limit = math.huge ,
150+ })
151+
152+ return vim
153+ .iter (solution_info and solution_info .projects or {})
154+ :map (function (proj )
155+ return proj .proj_file
156+ end )
157+ :any (function (proj_file )
158+ for _ , file in ipairs (project_files ) do
159+ if vim .fs .normalize (proj_file ) == vim .fs .normalize (file ) then
160+ return true
161+ end
149162 end
150- end
151- if vim .fs .normalize (dir ) == vim .fs .normalize (root ) then
152- break
153- end
154- end
155- end
156-
157- -- We cannot determine if the file is a test file without a project directory.
158- -- Keep searching the child by not filtering it out
159- if not project_dir then
163+ return false
164+ end )
165+ else
160166 return true
161167 end
162-
163- local solution_info = dotnet_utils .get_solution_info (solution )
164-
165- local found = vim .iter (solution_info and solution_info .projects or {}):any (function (project )
166- return vim .fs .normalize (project .proj_dir ) == vim .fs .normalize (project_dir )
167- end )
168-
169- if solution_info and not found then
170- return false
171- end
172-
173- return true
174168 end
175169
176170 local function get_match_type (captured_nodes )
@@ -403,7 +397,7 @@ local function create_adapter(config)
403397 local lang_tree =
404398 vim .treesitter .get_string_parser (content , filetype , { injections = { [filetype ] = " " } })
405399
406- local root = lib . treesitter . fast_parse ( lang_tree ) :root ()
400+ local root = lang_tree : parse ( false )[ 1 ] :root ()
407401
408402 local query = lib .treesitter .normalise_query (
409403 filetype ,
0 commit comments