monaco-languageclient
monaco-languageclient copied to clipboard
Multiple Monaco editor issue
I want to add multiple Monaco editors on one page. Demo code. Seems they share the same objects.
Declare "Aaa" in one editor could be referenced in the other.
Hi @bguo3 thank for reporting the issue and for supplying an example. That helps a lot!
@bguo3 sorry for the delay, but I was able to re-produce it:
https://github.com/TypeFox/monaco-components/blob/vscode-config/packages/examples/src/langium/wrapperLangium.ts
⬆️ This is the branch for v2. It now contains a Langium example with two editors and I see exactly your issue. Will try to find a solution, soon:
@bguo3 this currently happens because there is no logic preventing the same worker/connection being created twice for the same language identifier. You end up with two Language Servers answering your requests. If you have a different language in the second monaco-editor instance you don't see this problem.
v2 of the wrapper is a huge change. We will tackle this problem after it is released (release likely early May).
Hi, I am facing the same issue, would this be addressed in future version / is there a workaround for this?
Hi, I am facing the same issue, would this be addressed in future version / is there a workaround for this?
Hi @wa8f7192 No, there is no workaround for this. We need to properly fix it.
Hi @bguo3 and @kaisalmen I have finally started to solve this issue on this branch: https://github.com/TypeFox/monaco-languageclient/tree/issue-620
I now use two editors with just one language server worker and this removes the double completions, but both editor contents get mixed up with a completion request. This may be a Langium Language Server bug. I will come back with more info.
but both editor contents get mixed up with a completion request. This may be a Langium Language Server bug. I will come back with more info.
The observed behavior is correct. Top-level definitions are shared by the language server, therefore the completion request contains all top-level definitions in completion requests from both editors/documents.