monaco-languageclient icon indicating copy to clipboard operation
monaco-languageclient copied to clipboard

Multiple Monaco editor issue

Open bguo3 opened this issue 2 years ago • 6 comments

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. image

bguo3 avatar Jan 31 '23 06:01 bguo3

Hi @bguo3 thank for reporting the issue and for supplying an example. That helps a lot!

kaisalmen avatar Jan 31 '23 08:01 kaisalmen

@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: image

kaisalmen avatar Apr 20 '23 13:04 kaisalmen

@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).

kaisalmen avatar Apr 20 '23 14:04 kaisalmen

Hi, I am facing the same issue, would this be addressed in future version / is there a workaround for this?

wa8f7192 avatar May 16 '24 08:05 wa8f7192

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.

kaisalmen avatar May 16 '24 11:05 kaisalmen

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.

kaisalmen avatar May 24 '24 10:05 kaisalmen

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.

kaisalmen avatar May 27 '24 08:05 kaisalmen