prevent bundled library paths from being watched in resolution lookup#4197
prevent bundled library paths from being watched in resolution lookup#4197RyanCallahan312 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds logic to avoid watching embedded “bundled” TypeScript lib directories when building glob watch patterns, and introduces tests to verify bundled vs real lib directory behavior.
Changes:
- Skip adding
libDirectorywatch globs when the lib directory is identified as bundled/embedded. - Add unit tests for
createResolutionLookupGlobMapperto ensure bundled libs are ignored and real lib directories are watched.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/project/watch.go | Avoids adding lib-directory glob patterns when the lib directory is bundled. |
| internal/project/watch_test.go | Adds tests verifying bundled libs are skipped and real lib directories produce watch globs. |
| } else if currentDirectoryPath.ContainsPath(path) { | ||
| includeRoot = true | ||
| } else if libDirectoryPath.ContainsPath(path) { | ||
| includeLib = true | ||
| if !bundled.IsBundled(string(libDirectoryPath)) { | ||
| includeLib = true | ||
| } |
| mapper := createResolutionLookupGlobMapper("/workspace", bundled.LibPath(), "/workspace", true) | ||
| result := mapper(data) | ||
|
|
||
| assert.DeepEqual(t, result.patternsInsideWorkspace, []string(nil)) |
|
We aren't really intending on anyone using bundled mode; how did you end up in this situation? |
|
@microsoft-github-policy-service agree |
I'm not sure myself because afaik I'm not doing anything special. I'll try to get a minimal reproduction of a neovim config and project in the next day or so. Quick summary on my neovim setup and project until then:
|
This is what I'm referring to. If I look, I find: https://github.com/mason-org/mason-registry/blob/0b4f69c201865c65e037a5ef0a7fa3bf1a7d7817/packages/tsgo/package.yaml#L16 Which uses our npm package, which does not build with embedding. So I still don't know how you're getting something built that way. |
Background
I was setting up the tsgo lsp in my neovim config and ran into this error in a medium sized project managed with turborepo
I found this is because neovim treats
workspace/didChangeWatchedFilesglob patterns as filesystem globs. As a result neovim rejectsbundled:///libs/**/*because it's a URI-like, but not a filesystem path.Change Details
In
internal/project/watch.go,createResolutionLookupGlobMappernow checks whether the library directory is a bundled path viabundled.IsBundled()before settingincludeLib = true. This prevents the glob mapper from adding watch patterns for embeddedlib.d.tsfiles that are not real filesystem paths.Two test cases were added to
watch_test.goto verify:bundled.Embeddedis true).AI Disclosure
This patch was authored with the assistance of an AI coding agent. I have reviewed the changes and will personally respond to any review feedback. Admittedly I do not fully understand the scope of this area of the codebase, but to the best of my knowledge I believe it to be safe.
Additionally, I've tested that it resolves my specific lsp issue in neovim.