-
Hello, We are developing a VS Code extension that uses Langium. We are developing a table editor that edits models generated from a Langium DSL. We noticed an issue that happens due to VS Code's Hot Exit. Let's say the DSL has text "Old Value". Through our table editor, code actions are performed that changes the DSL text to "New Value". Then, without saving, VS Code is closed and reopened. Due to Hot Exit, the contents of the DSL file on the local file system is still "Old Value", though the content displayed in the DSL editor in VS Code is "New Value". We see that a textDocument/didOpen notification is sent, with content "New Value". However, when the table editor requests the model from Langium, a notification is sent with value "Old Value". This seems to break the connection between our table editor and the Langium document, as any edits in the table now do not work properly and cause errors. We do not send any textDocument/didOpen notifications, so I assume this is coming through VS Code and because of Hot Exit gives the content of the text editor to be "New Value". However, it seems that the Langium document actually (rightly) sends the model of the actual file contents on the file system, and not what is displayed in the VS Code editor. Due to various github issues I have seen on VS Code's github (e.g. this) they seem to think that Hot Exit is a useful feature and have no desire to address any of the various issues that could come about because of it. Because we have no control over whether people who use our extension will have Hot Exit on or off, it seems we must solve this problem on our side. Do you have any idea of a good way we could rectify the content of the editor in VS Code possibly being different from the Langium document's contents? Perhaps get the content of the VS Code editor somehow and send a code action to the language server and update it, maybe on extension start or editor opening? Thank you for your time. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey @Greglar4, I am a bit confused. Usually Langium has absolutely no issues with VS Code's hot exit. The way this works is:
I am wondering why the document does not change in your case. Is your code available somewhere or can you provide a reproducible example? |
Beta Was this translation helpful? Give feedback.
-
I attempted making a MRE but the problem didn't appear there. Also, we switched from using npm to pnpm, and then the problem went away. We're assuming the cause of the issue was dependency specific, and changing to pnpm caused our dependencies to change. |
Beta Was this translation helpful? Give feedback.
I attempted making a MRE but the problem didn't appear there.
Also, we switched from using npm to pnpm, and then the problem went away. We're assuming the cause of the issue was dependency specific, and changing to pnpm caused our dependencies to change.