I use the Monaco Editor.
My full code is too long to be posted here but this is my settings:
automaticLayout: true,
folding: false,
theme: 'vs-dark',
lineNumbers: 'off',
minimap: {
enabled: false
}
How can I force a resize that I can trigger from my script?
What did happend was that the console message was output on every window change, but not the Monaco height.
window.onresize = () => {
console.log('Window resize');
editor.layout();
});
I enlarge first and then reduce the height by making the developer console larger/smaller.

We have grappled with this too. The answer is to make the layout take an empty object rather than no parameter, so the resize function becomes
window.onresize = () => {
console.log('Window resize');
editor.layout({});
});
Note that typescript does not like this, as the object apparently should contain both width and height.
window.onresize = () => {
console.log('Window resize');
editor.layout({} as monaco.editor.IDimension);
});
Fixes that issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With