From 24f99f0d93aa9b71abb72ef8c89bc939cca71b78 Mon Sep 17 00:00:00 2001 From: Austin Cherry Date: Thu, 26 Feb 2026 13:42:57 -0600 Subject: [PATCH] fix(lsp): replace recursive fastwalk with filepath.Glob in root marker detection (#2316) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- internal/lsp/manager.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/lsp/manager.go b/internal/lsp/manager.go index f436b3cb3433d9c7e6c5ef28a3cff8bfa17f447f..5e238fda296a5e28034482a3a0b163ae1ae04d6c 100644 --- a/internal/lsp/manager.go +++ b/internal/lsp/manager.go @@ -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 }