Skip to content

Commit

Permalink
Merge pull request #597 from ckipp01/noSearchRoot
Browse files Browse the repository at this point in the history
fix: don't consider / as a valid root
  • Loading branch information
ckipp01 authored Aug 17, 2023
2 parents fa2616f + f04cec7 commit 57cff9a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lua/metals/rootdir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ end
--- for the behavior described above.
local find_root_dir = function(patterns, startpath, maxParentSearch)
local path = Path:new(startpath)
-- TODO if we don't find it do we really want to search / probably not... add a check for this
-- First parent index in which we found a target file
local firstFoundIdx = nil
local ret = nil
local found = nil

for i, parent in ipairs(path:parents()) do
-- Exit loop before checking anything if we've exceeded the search limits
if firstFoundIdx and (i - firstFoundIdx > maxParentSearch) then
if (firstFoundIdx and (i - firstFoundIdx > maxParentSearch)) or parent == "/" then
return ret
end

Expand Down

0 comments on commit 57cff9a

Please sign in to comment.