fix(lsp): replace recursive fastwalk with filepath.Glob in root marker detection (#2316)
Austin Cherry
created
hasRootMarkers used fsext.Glob which triggered a full recursive fastwalk
of the working directory with no gitignore filtering. In large JS
monorepos this walked millions of files in node_modules, causing 800%
CPU usage. Root markers are simple filenames (go.mod, package.json,
*.gpr, etc.) that only need a single-directory check.
🐘 Generated with Crush
Assisted-by: AWS Claude Opus 4.6 via Crush <crush@charm.land>
@@ -303,8 +303,10 @@ func hasRootMarkers(dir string, markers []string) bool {
return true
}
for _, pattern := range markers {
- // Use fsext.GlobWithDoubleStar to find matches- matches, _, err := fsext.Glob(pattern, dir, 1)
+ // Use filepath.Glob for a non-recursive check in the root
+ // directory. This avoids walking the entire tree (which is
+ // catastrophic in large monorepos with node_modules, etc.).
+ matches, err := filepath.Glob(filepath.Join(dir, pattern))
if err == nil && len(matches) > 0 {
return true
}