Skip to content

Commit

Permalink
refactor: deprecate util.path.iterate_parents
Browse files Browse the repository at this point in the history
Work on #2079.
  • Loading branch information
dundargoc committed Dec 22, 2024
1 parent d68378c commit 9204642
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/ci/run_sanitizer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANC
exit 1
fi

SEARCH_PATTERN='(util\.path\.dirname|util\.path\.sanitize|util\.path\.exists|util\.path\.is_file|util\.path\.is_dir|util\.path\.join|util\.find_mercurial_ancestor|util\.find_node_modules_ancestor|util\.find_package_json_ancestor|util\.find_git_ancestor)'
SEARCH_PATTERN='(util\.path\.dirname|util\.path\.sanitize|util\.path\.exists|util\.path\.is_file|util\.path\.is_dir|util\.path\.join|util\.path\.iterate_parents|util\.find_mercurial_ancestor|util\.find_node_modules_ancestor|util\.find_package_json_ancestor|util\.find_git_ancestor)'

if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANCH}" -- '*.lua' | grep -Ev '\.lua$' | grep -E "^\+.*${SEARCH_PATTERN}" ; then
echo
Expand Down
23 changes: 4 additions & 19 deletions lua/lspconfig/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,6 @@ M.path = (function()
end
end

-- Iterate the path until we find the rootdir.
local function iterate_parents(path)
local function it(_, v)
if v and not is_fs_root(v) then
v = vim.fs.dirname(v)
else
return
end
if v and vim.loop.fs_realpath(v) then
return v, path
else
return
end
end
return it, path, path
end

local function is_descendant(root, path)
if not path then
return false
Expand All @@ -160,7 +143,6 @@ M.path = (function()

return {
traverse_parents = traverse_parents,
iterate_parents = iterate_parents,
is_descendant = is_descendant,
}
end)()
Expand All @@ -173,7 +155,7 @@ function M.search_ancestors(startpath, func)
return startpath
end
local guard = 100
for path in M.path.iterate_parents(startpath) do
for path in vim.fs.parents(startpath) do
-- Prevent infinite recursion if our algorithm breaks
guard = guard - 1
if guard == 0 then
Expand Down Expand Up @@ -363,6 +345,9 @@ end
--- @deprecated use `vim.fn.has('win32') == 1 and ';' or ':'` instead
M.path.path_separator = vim.fn.has('win32') == 1 and ';' or ':'

--- @deprecated use `vim.fs.parents(path)` instead
M.path.iterate_parents = vim.fs.parents

--- @deprecated use `vim.fs.dirname(vim.fs.find('.hg', { path = startpath, upward = true })[1])` instead
function M.find_mercurial_ancestor(startpath)
return vim.fs.dirname(vim.fs.find('.hg', { path = startpath, upward = true })[1])
Expand Down

0 comments on commit 9204642

Please sign in to comment.