aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lspconfig/util.lua')
-rw-r--r--lua/lspconfig/util.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 625d3170..542d13eb 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -161,15 +161,16 @@ M.path = (function()
-- Iterate the path until we find the rootdir.
local function iterate_parents(path)
- path = uv.fs_realpath(path)
local function it(s, v)
- if not v then
+ if v and not is_fs_root(v) then
+ v = dirname(v)
+ else
return
end
- if is_fs_root(v) then
+ if not uv.fs_realpath(v) then
return
end
- return dirname(v), path
+ return v, path
end
return it, path, path
end
@@ -263,7 +264,14 @@ function M.search_ancestors(startpath, func)
if func(startpath) then
return startpath
end
+ local guard = 100
for path in M.path.iterate_parents(startpath) do
+ -- Prevent infinite recursion if our algorithm breaks
+ guard = guard - 1
+ if guard == 0 then
+ return
+ end
+
if func(path) then
return path
end