-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add secondary window support for text editors #13493
Conversation
0b4d0e7
to
c2234d1
Compare
There was a problem hiding this 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.
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 adevDependency
in their rootpackage.json
- specify
postinstall: patch-package --patch-dir node_modules/@theia/core/patches
in their rootpackage.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.
}, | ||
{ | ||
test: /\.wasm$/, | ||
type: 'asset/resource' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
packages/core/src/browser/menu/browser-context-menu-renderer.ts
Outdated
Show resolved
Hide resolved
packages/editor/package.json
Outdated
@@ -45,4 +46,4 @@ | |||
"nyc": { | |||
"extends": "../../configs/nyc.json" | |||
} | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: keep the newline?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
The copy action actually works, but it copies from the main window's document ( |
@sdirix this works just fine for me on Electron/Windows. What's different? |
ac70f38
to
06dda74
Compare
- 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 <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
06dda74
to
cbfc698
Compare
Signed-off-by: Thomas Mäder <[email protected]>
There was a problem hiding this 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.
@rschnekenbu what's missing for an approval? |
There was a problem hiding this 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 ;)
What it does
Adds secondary windows support for monaco text editors.
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