This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Repository navigation
Allow LSP server to use builtin watcher on Windows and macOS - #4288
Merged
Andrew Branch (andrewbranch) merged 4 commits intoJun 12, 2026
Merged
Andrew Branch (andrewbranch) merged 4 commits into
Andrew Branch (andrewbranch) merged 4 commits into
Conversation
Adds an in-process file watcher (lspwatcher) that the LSP server uses instead of LSP-based file watching when the client lacks dynamic watch registration, or when the useBuiltinWatcher initialization option is set. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an in-process (“builtin”) file watching fallback for the TypeScript-Go LSP server on platforms where recursive watching is efficient (Windows and macOS/FSEvents), so the server can still receive workspace/didChangeWatchedFiles-shaped events even when the LSP client lacks dynamic watch registration.
Changes:
- Enable builtin watcher fallback in
internal/lsp/server.gowhen the client lacks dynamicworkspace/didChangeWatchedFilesregistration and the default fswatch backend is fast-recursive. - Introduce
internal/lsp/lspwatcherto translatefswatchevents into LSPFileEventbatches, including logic for missing directories and recovery after directory deletion. - Add
fswatch.DefaultHasFastRecursiveBackend()helpers and comprehensive unit tests for the new watcher behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/lsp/server.go | Selects between client-driven watching and builtin in-process watching; wires builtin watcher into session change notifications and shutdown. |
| internal/lsp/lspwatcher/lspwatcher.go | New in-process watcher implementation that maps fswatch subscriptions to LSP watcher registrations and batches events. |
| internal/lsp/lspwatcher/lspwatcher_test.go | Tests covering event forwarding, kind filtering, missing-directory promotion, termination recovery, and rollback behavior. |
| internal/fswatch/watcher.go | Adds helpers to detect whether the default watcher backend supports efficient recursive watching. |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Jake Bailey (jakebailey)
approved these changes
Jun 12, 2026
Christian Vuerings (christianvuerings)
added a commit
to christianvuerings/typescript-go
that referenced
this pull request
Jun 12, 2026
* origin/main: Make LS checkers time out after being idle, segment based on use (take 2) (microsoft#3435) Fix external helper crash after module-status updates (microsoft#3994) Allow LSP server to use builtin watcher on Windows and macOS (microsoft#4288) Rebuilt CLI watcher around new `fswatch` package (microsoft#4026) Fix stack overflow crash in base constraint resolution (microsoft#4242) # Conflicts: # internal/project/session.go
Jake Bailey (jakebailey)
pushed a commit
to jakebailey/TypeScript
that referenced
this pull request
Aug 13, 2026
…ft/typescript-go#4288) Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]>
This was referenced Nov 16, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
You can't yet opt into this, and won't enable at all outside of Windows and macOS, because the work to make the backends that require marking every directory in a tree work efficiently is a lot bigger, and I've extracted into a separate branch that we can look into when less crunched for time.