fix(utils): replace vim.fn.glob with vim.uv.fs_scandir to fix checkhealth hang#15
Merged
Conversation
…n_upwards vim.fn.glob can block Neovim for seconds when scanning large directories (e.g. home folder, NFS mounts). Replaced with vim.uv.fs_scandir for suffix patterns (*.xcworkspace, *.xcodeproj). Also adds a max_depth=10 guard to prevent traversal all the way to /.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2 — the actual root cause identified by live testing in Neovim.
Problem
checkhealth swiftwas hanging at the Project Detection section with a Keyboard Interrupt. The culprit wasvim.fn.glob()insidefind_pattern_upwards()inutils.lua.vim.fn.glob()calls the OSreaddir()+ shell glob expansion synchronously, blocking Neovim's main thread. On macOS, when the current directory tree contains many files (e.g. your home folder or an NFS mount), this can freeze Neovim indefinitely.Fix
Replaced
vim.fn.glob()withvim.uv.fs_scandir()(libuv's native directory scanner) for suffix-based patterns like*.xcworkspaceand*.xcodeproj. Also adds amax_depth = 10guard so the search never walks all the way to/.Benchmark (headless Neovim, tested locally)
Also includes
tests/test_health_speed.luato catch regressions