-
Notifications
You must be signed in to change notification settings - Fork 178
feat: Add support for --canUseWatchEvents and watch event forwarding
#1057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: Add support for --canUseWatchEvents and watch event forwarding
#1057
Conversation
--canUseWatchEvents and watch event forwarding--canUseWatchEvents and watch event forwarding
|
I have actually been working on it last week and came quite far. One thing that was a bit problematic was to adapt the watcher ID concept into LSP where there are no IDs. Curious to check how you've handled that. After I'll check the changes out we'll have to decide which changes to go with based on what would be more efficient. |
|
After cursory look I have some comments but I think it would be better to just go with my version of the code which is based on vscode's implementation more closely as that makes maintenance easier. Some notes (but not sure you should spend time on those given what I said above):
|
|
I appreciate your efforts on getting registrations aggregated. Since tsserver is very granular in its events, I think your approach makes sense where you mainly just watch the root and match against tsserver watchers once the events are received. That said, I would still prefer to match vscode more closely in some parts. Perhaps we can work together on this branch to get it working and finalized? That would be more efficient than going through PR comments. Alternatively I could work on my branch and potentially pick some stuff from you. |
Thanks so much for the detailed review and for taking the time to run and investigate my implementation. I really appreciate the explanations, a lot of these areas were things I didn’t fully understand when I started, and I learned a lot while working on this. I’m glad some of the ideas were useful. Since you already have a more complete implementation underway, I think it makes the most sense for you to continue with your version. Please feel free to take anything from my branch that helps. |
|
No problem. Lets work on this together then. I can push to the branch so it should be easy and we can discuss things as we go. |
|
@rchl |
Fixes #956
This PR adds optional support for a new TypeScript server feature that allows the editor to provide file watch events instead of having tsserver watch all files directly. When enabled and supported, this can significantly reduce the number of filesystem watchers in large workspaces.
Changes:
--canUseWatchEvents--canUseWatchEventsto tsserver when supportedWatchEventManagerto track tsserver watcher requests and manage dynamic workspace watcherswatchChangerequestcreateFileWatcher,createDirectoryWatcher,closeFileWatcherWhen this feature is enabled and all requirements are satisfied the server will:
--canUseWatchEventsDidChangeWatchedFilesevents to tsserver aswatchChangenotificationsNotes:
Requires TypeScript >= 5.4 and client support for dynamic watched-files registration and relative patterns. And if any prerequisite is missing, a warning is logged and the server continues with normal tsserver file watching, so no behavior change for existing users.