-
Notifications
You must be signed in to change notification settings - Fork 74
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
Langium documents don't get removed after the containing directory is renamed #1230
Comments
@lars-reimann Thanks for the report. I believe this is part of a larger issue where we don't actually listen to a few of the workspace related LSP notifications, mainly:
Some of these are not interesting for the default behavior of Langium, but we should definitely start handling the |
I had a closer look at this. We already get notifications of most changes through |
see also didClose in #1281 |
I experimented with adding / removing workspace folders with Langium documents and did not see any issues. So it seems we don't need to handle A service for the file operations is introduced in #1286, but as mentioned in that PR, those notifications should not be used to trigger DocumentBuilder updates. They are rather meant to enhance the user experience when working with the IDE, e.g. by automatically changing some text content when you rename a file (we could make use of that for langium file renaming). The remaining question is how to fix the issue reported here. My current understanding is that we should use the file system watcher for that by adding a suitable glob pattern and handling it. |
While reviewing and testing your changes of #1286 I could produce a corrupt state of Thus listening to |
But I agree. The language server should listen to it. |
@msujew you're right, I didn't check the spec, which is saying "about workspace folder configuration changes" |
This seems not to be possible in an adequate way, see microsoft/vscode#60813 An explicit remark on that was deleted with https://github.com/microsoft/vscode/pull/139881/files#diff-0a75aed19c118603eb96332bc0b9c2d7867f4182346d16d18b7fc31b6ceeb321L10951-L10952 beginning of last year. I could make notifications on folder name changes work with a glob pattern like |
Has anyone developed a workaround for this issue? |
FYI, there are seemingly workarounds for this, but they cannot be implemented on the language server side (i.e. we cannot implement them in Langium). Instead, they require changes to the language client. See stinb/UnderstandForVSCode@62eef64#diff-cae88b2ea25f713b20b6aa35c12ae6cf520b11d806be403dfb04cb28f612275aL124. Langium listens correctly to all language client events. It's just that the vscode-languageclient (or vscode in general) doesn't correctly send the events when the folder is renamed. |
I've provided a PR for this over at #1786. Note that this issue isn't specific to renaming but also applies to any directory deleting operation. To the language server, a rename is just a delete+update notification. |
After renaming a directory, all DSL files contained inside are listed twice in
services.shared.workspace.LangiumDocuments
. This can affect various downstream features, like linking, type computation, or validation.Langium version: 2.0.2
Package name: langium
Steps To Reproduce
services.shared.workspace.LangiumDocuments
. In the repo linked below, it gets logged in the output panel..hello
for the repo linked below).Link to code example: https://github.com/lars-reimann/langium-cst-range
The current behavior
Before renaming the directory, the document is included (correct):
After renaming (third array), the new document is shown (correct), but the old one is not deleted (wrong):
The expected behavior
Only the new document should be included.
The text was updated successfully, but these errors were encountered: