Skip to content
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

Add secondary window support for text editors #13493

Merged
merged 10 commits into from
Mar 27, 2024

Conversation

tsmaeder
Copy link
Contributor

@tsmaeder tsmaeder commented Mar 14, 2024

What it does

Adds secondary windows support for monaco text editors.

  • moves hard-coded support for webviews in secondary windows into the webviews support
  • introduces patch-package as a way to manage Phosphor patches
  • fixes the context menu support in secondary windows

fixes #13163, #12722, #3203

contributed on behalf of STMicroelectronics

Note that this PR introduces patch-package as a way to manage PhosphorJS patches. This choice is controversial, as it introduces the burden to do the same when building a theia-based product. Discussion of alternatives can and should be happening on this PR, IMO. I'm opening the PR now in order to allow for testing and code-review, because the mechanism of patching PhosphorJS is irrelevant to those concerns.

Note: #13214 is not part of this PR.

How to test

Extract monaco editors to secondary windows an make sure the normal editor functionality works in the secondary window. This should include the browser and electron case and navigation among editors.

Follow-ups

Review checklist

Reminder for reviewers

@tsmaeder tsmaeder force-pushed the 13163_extractable_editors branch 2 times, most recently from 0b4d0e7 to c2234d1 Compare March 18, 2024 13:18
.theia/settings.json Outdated Show resolved Hide resolved
Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a rough look over the code but not in detail. I also tested the changes in the Electron example and Browser example.

Extracting editors seems to work fine in both Browser and Electron! Nice!

I found one issue in Electron. The "minimap" overview in the top right does not appear initially. Only when resizing the window horizontally, the "minimap" appears.
image

I also tested web view VS code extensions and extracting them still works 👍


We must think about the adopter story too. To get this feature in, adopters will also need to execute the patching themselves. This means they will need to:

  • add patch-package as a devDependency in their root package.json
  • specify postinstall: patch-package --patch-dir node_modules/@theia/core/patches in their root package.json

This must be mentioned in the breaking changes, however still many users will at first fail to do so. We will also need to adapt documentation and projects like the yeoman theia-generator.

It would be great if the patching was optional, i.e. if the user did not patch then Theia still works as intended, just that the secondary window feature does not work. Bonus points if the cause can be detected and an error is logged.

Looking at the patches, they mostly seem to introduce additional optional parameters. I quickly tested the Electron example application without applying the patches. I had to fix a typing error in browser-menu-plugin.ts, however besides that everything built and worked fine! Of course the secondary window feature then stopped working, but that is expected.

In the long run we are hopefully able to switch from PhosphorJS to Lumino and contribute these changes in a compatible way. Then we can get rid of the patching again.

Comment on lines +265 to +268
},
{
test: /\.wasm$/,
type: 'asset/resource'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I recall correctly, the monaco editor uses wasm for tokenizing and the wasm files were not included in the bundle.

patches/@phosphor+widgets+1.9.3.patch Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must this be solved via patch? Can't we modify and publish a new @theia/monaco-editor-core ourselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already fixed in the current version of VS Code. Maintaining patches in our rebuilt version of VS Code is not something I want to start. The alternative, IMO is to patch it here or to leave the resizing of peek-views broken until we update monaco.

@@ -45,4 +46,4 @@
"nyc": {
"extends": "../../configs/nyc.json"
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: keep the newline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the formatter that does this: only turning off "format on save" allows to keep the newline, see above.

Copy link
Contributor

@rschnekenbu rschnekenbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current support is already great! I tested on browser and electron.
The current limitation I could see along the ones already documented was the copy and paste not working properly on text editors. I tested on a 2nd window with the drawio extension, and that seems to work in case of diagram editors. I tried in text editors both with context menu and shortcuts, they don't work in my case. It can still paste if there was some string in the clipboard, but copy and cut do not update the clipboard.
Otherwise, theme is supported in new window, navigation works as expected, most actions I could test were working also as expected, as for example rename symbol and its shortcut.

@tsmaeder
Copy link
Contributor Author

The copy action actually works, but it copies from the main window's document (document.execCommand('copy');).

@tsmaeder
Copy link
Contributor Author

I found one issue in Electron. The "minimap" overview in the top right does not appear initially. Only when resizing the window horizontally, the "minimap" appears.

@sdirix this works just fine for me on Electron/Windows. What's different?

- moves hard-coded support for webviews in secondary
windows into the webviews support
- introduces patch-package as a way to manage Phosphor patches
- fixes the context menu support in secondary windows

fixes eclipse-theia#13163, eclipse-theia#12722

contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
Copy link
Contributor

@rschnekenbu rschnekenbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good to me on code and behavior aspect (both electron and browser).
I don't have any constructive comment on patch-package usage and if there are better alternatives here.

@tsmaeder
Copy link
Contributor Author

@rschnekenbu what's missing for an approval?

Copy link
Contributor

@rschnekenbu rschnekenbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tsmaeder, looking good to me. I am of course leaving space for other committers to discuss on patch-package, but for what I can review, this is approved ;)

@tsmaeder tsmaeder merged commit a47ddeb into eclipse-theia:master Mar 27, 2024
14 checks passed
@jfaltermeier jfaltermeier added this to the 1.48.0 milestone Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[feature-request]: Floating editor windows
4 participants