Skip to content

prevent bundled library paths from being watched in resolution lookup#4197

Open
RyanCallahan312 wants to merge 1 commit into
microsoft:mainfrom
RyanCallahan312:virtual-file-watcher
Open

prevent bundled library paths from being watched in resolution lookup#4197
RyanCallahan312 wants to merge 1 commit into
microsoft:mainfrom
RyanCallahan312:virtual-file-watcher

Conversation

@RyanCallahan312
Copy link
Copy Markdown

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

LSP[tsgo]: Error SERVER_REQUEST_HANDLER_ERROR: "...Cellar/neovim/0.12.2/share/nvim/runtime/lua/vim/glob.lua:373: Invalid glob: bundled:///libs/**/*"

I found this is because neovim treats workspace/didChangeWatchedFiles glob patterns as filesystem globs. As a result neovim rejects bundled:///libs/**/* because it's a URI-like, but not a filesystem path.

Change Details

In internal/project/watch.go, createResolutionLookupGlobMapper now checks whether the library directory is a bundled path via bundled.IsBundled() before setting includeLib = true. This prevents the glob mapper from adding watch patterns for embedded lib.d.ts files that are not real filesystem paths.

Two test cases were added to watch_test.go to verify:

  1. Bundled library paths are correctly skipped (when bundled.Embedded is true).
  2. Real (non-bundled) library directories are still included in the watch patterns.

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.

Copilot AI review requested due to automatic review settings June 4, 2026 02:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 libDirectory watch globs when the lib directory is identified as bundled/embedded.
  • Add unit tests for createResolutionLookupGlobMapper to 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.

Comment thread internal/project/watch.go
Comment on lines 298 to +303
} 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))
@jakebailey
Copy link
Copy Markdown
Member

We aren't really intending on anyone using bundled mode; how did you end up in this situation?

@RyanCallahan312
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@RyanCallahan312
Copy link
Copy Markdown
Author

We aren't really intending on anyone using bundled mode; how did you end up in this situation?

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:

@jakebailey
Copy link
Copy Markdown
Member

jakebailey commented Jun 4, 2026

  • tsgo installed globally with mason

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants