Skip to content
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

(fix) move fs watcher config to language-server #2009

Merged
merged 1 commit into from
May 10, 2023

Conversation

jasonlyu123
Copy link
Member

#2008

The problem seems to be becuase neovim recently added the didChangeWatchedFiles support. But they didn't have a watcher config on their side. This PR move the watcher config to the language server with dynamic registration. It was on the client side because it can't be set in the server as a capability.

Existing clients with the config I know of are VSCode, coc-svelte, visual studio and emacs-lsp. I tested with them to see if moving to the server side would cause any problems. VSCode and coc-svelte can handle both and will not trigger twice. Visual Studio doesn't support dynamic registration this won't affect it. I didn't manage to install emacs-lsp successfully. But the Volar client in emacs does have this double registration problem, and it doesn't seem to have an existing issue, so it's probably fine.

I also added json to the watcher config. So this should fix #1613 as well. In resolveJsonModule, json file is just like ts, js files and in normal mode, We'll still cache some JSON files because TypeScript reads them through languageServiceHost.readFile. We can refresh those in the file watch as well.

@dummdidumm
Copy link
Member

will not trigger twice

When and where would it trigger twice, or rather, where did you fear it would and why?

@jasonlyu123
Copy link
Member Author

jasonlyu123 commented May 10, 2023

I am just worried that some clients have the watch config as we do. And now we have added an extra one to the server. File watch event might trigger twice. But triggering twice is probably fine, just a slight performance penalty. This won't affect VSCode since I removed it, testing in VSCode is just trying to see how clients might react to it.

@dummdidumm
Copy link
Member

Aah I understand, so the worry is that language clients which have a watcher config on the client side need to adjust/remove that config if they want to use the latest language server version and not have file updated triggered twice. I'm ok with this, especially since it doesn't seem to make a difference (only in performance a bit) in your testing.

@dummdidumm dummdidumm merged commit 9dd59e0 into sveltejs:master May 10, 2023
2 checks passed
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.

Language server does not refresh JSON imported with resolveJsonModule
2 participants