Discrepancies using vscode.Selection in Theia vs VSCode (VSIX) when there are multiple editor types per file #16964
-
QuestionHey there, We have a VSIX plugin that we deploy into a Theia browser instance. Part of our main functionality is that we have multiple different editor per file, for example a table editor and a DSL (Langium) editor. Whilst testing some new navigation features we noticed that if you have both editors open, the selection method on the TextEditor becomes flakey. It might work initially but after that it stops highlighting the text until you close both of the editors and reopen. It works fine when you solely have the text editor open. And the issue doesn't happen at all in VSCode. Currently using Theia 1.68 and I made sure our vscode engine versions matches the supported version for Theia The function we use for this is fairly simple: Cheers |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
|
Hi @jmenzies12, thanks for starting this discussion! 👋 The Theia community will take a look soon. In the meantime, you might find helpful information in: 💙 Eclipse Theia is built and maintained by a community of contributors and sponsors. If Theia is valuable to your work, consider sponsoring the project. For professional support, training, or consulting services, learn more about available options. |
Beta Was this translation helpful? Give feedback.
-
|
@jmenzies12 Hi Jonathan! That is very interesting and purely from the code I agree that it should work. Could you let me a little bit more about your setup: You have editors for that file (text and table) and both of them are open at open at the same time. Are they both on the root level? Do they share the same URI? Which one is the default? Does it make a difference which editor was opened first? I tried to test this on a similar project but the command always opens the default editor. I tried to reproduce this in a project with a similar setup and I can reproduce a behavior where the highlight does not work at all once you open another editor for the same URI. As far as I can tell it is caused by this: Visibility Change (e.g., selecting another tab) causes the model to be set to null for some workaround: theia/packages/monaco/src/browser/monaco-editor.ts Lines 266 to 277 in 793ca84 Model setting to null leads to editor disposal: theia/packages/plugin-ext/src/main/browser/text-editor-main.ts Lines 98 to 100 in 793ca84 Which in turn leads to any selection being set to be "ignored" as we do not have the editor anymore: theia/packages/plugin-ext/src/main/browser/text-editor-main.ts Lines 142 to 149 in 793ca84 Could you maybe debug your code to confirm that this is the issue? I'm not yet sure why some of the code does this but at we can open an issue for it and maybe you can fix the problem locally if that is the case. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @martin-fleck-at, Thanks for opening #17064 👍 I’ve confirmed through debugging that the root cause is indeed the This behavior differs from VS Code, where multiple editors sharing the same URI do not invalidate the text editor instance in this way. If helpful, I’m happy to:
Thanks again for investigating this so quickly. |
Beta Was this translation helpful? Give feedback.
Great, thank you! I opened #17064 for it.