fix(util): check that root_dir exists. Fixes #56. Closes #51

This commit is contained in:
Folke Lemaitre 2024-07-07 00:03:25 +02:00
parent 255693b005
commit f9dcd17b95
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 5 additions and 4 deletions

View File

@ -53,12 +53,13 @@ function M.on_config(opts)
if opts.root_dir then
local root_dir = initial_config.root_dir
initial_config.root_dir = function(...)
local b = root_dir(...)
if not b then
return
end
local a = opts.root_dir(...)
local b = root_dir and root_dir(...)
if not b then
return a
end
if a and b then
-- return longest
return #a > #b and a or b