@@ -295,35 +295,32 @@ function Api.get_project_root(bufnr)
295295 return false
296296 end ,
297297 }
298- local roots = {} --- @type { [1] : string , [2] : string , [3] : ' lsp' | ' pattern' } []
298+ local roots = {} --- @type { root : string , method_msg : string , method : ' lsp' | ' pattern' } []
299299 local root , lsp_method = nil , nil
300300 local ops = vim .tbl_keys (SWITCH ) --- @type string[]
301301 local success = false
302302 for _ , method in ipairs (Config .detection_methods ) do
303303 if in_list (ops , method ) then
304304 success , root , lsp_method = SWITCH [method ]()
305305 if success then
306- table.insert (roots , { root , lsp_method , method })
306+ table.insert (roots , { root = root , method_msg = lsp_method , method = method })
307307 end
308308 end
309309 end
310310
311311 if vim .tbl_isempty (roots ) then
312312 return
313313 end
314- if # roots == 1 then
315- return roots [1 ][ 1 ] , roots [1 ][ 2 ]
314+ if # roots == 1 or Config . options . lsp . no_fallback then
315+ return roots [1 ]. root , roots [1 ]. method_msg
316316 end
317- if Config .options .lsp .no_fallback then
318- return roots [1 ][1 ], roots [1 ][2 ]
319- end
320- if roots [1 ][1 ] == roots [2 ][1 ] then
321- return roots [1 ][1 ], roots [1 ][2 ]
317+ if roots [1 ].root == roots [2 ].root then
318+ return roots [1 ].root , roots [1 ].method_msg
322319 end
323320
324321 for _ , tbl in ipairs (roots ) do
325- if tbl [ 3 ] == ' pattern' then
326- return tbl [ 1 ] , tbl [ 2 ]
322+ if tbl . method == ' pattern' then
323+ return tbl . root , tbl . method_msg
327324 end
328325 end
329326end
0 commit comments