You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letlocalStorage_fontSize='';functioncreateEditor(){constoptions={value: '<div>Some text goes here</div>',language: "html",fontSize: 12,};constfontSize=localStorage_fontSize;if(fontSize&&/\d+(\.\d+)?/.test(fontSize)){options.fontSize=parseFloat(fontSize);}consteditor=monaco.editor.create(document.getElementById("editor"),options);// listen font size change and save new value in local storageeditor.onDidChangeConfiguration((e)=>{if(!e.hasChanged(monaco.editor.EditorOption.fontSize)){return;}localStorage_fontSize=editor.getOption(monaco.editor.EditorOption.fontSize).toString();});returneditor;}leteditor=createEditor();document.getElementById('create').addEventListener('click',function(){editor=createEditor();});document.getElementById('destroy').addEventListener('click',function(){editor.dispose();});
Font size changes twice. Instead of 13.2px (lets assume we are increasing font size and default value was 12px) it becomes 14.52px.
Expected Behavior
The font size does not change after instance re-creation.
Additional Context
It's easy to reproduce when you use any client router and monaco editor at the same time. In my case it's react-router. When I change font size, navigate away from the page and come back - font size changes one more time.
The text was updated successfully, but these errors were encountered:
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Link
https://microsoft.github.io/monaco-editor/playground.html?source=v0.52.0#XQAAAAJqBAAAAAAAAABBqQkHQ5NjdVKIfkDi6SE6eJIbQyteFotciG7lKwh8wfIZ36OGD47nBRTK6zV7toIBs2O5GCJoRJ17GWu3dzLMrVeQg8lDNo5C5IsGbN5X3yVU_goa8kylb35AgX74t8fhMsaN38UxRlwliqsgRHk8DKKEdEFxy49_9oP8-yYptg-YyxPV3HkgXmYD4GCxG7xOT0Fl2GSHFKfVgCika6sWhJNLchhy2FKthrpxv8q-oGs9RoVe-fzST8bhsxCMZIaYN3sU_eOkQ0uVAM4K4K5JEZDqfe00scutsdHdg67Y8znXuXetLU7CoWmy10Gc-W5jv0UzVvrAjD_VY_0nBdRJRiL6l8AsBhBSg2OsPLgzgAxyYopcdu5GNtobz7hopLs2tCZL7IlxPujK_pv_NNrKE1KngzKT3FzpuHrf5zUkS5WlH9MoJ2l0bSMSBvN7GT_psjGJjO9p3kE3lkVsRMJyBRrB8mmEHsY_LKVTTOatXVoPokJI7y_qYaGRBQR7BHVfpcVkHF-lkomo0Ujz6O8ZLHQUl3sOMK4n09YJszoHq4lqLbftFmTrXdcN6M-NnSfjxfD5-dDIUS13e7FIIYnHidXqRcRwv1vVDjnviRFLn3F1beuOBhjHsxy5GOTGVNhoa7K99Zu6RRkbbFKFjffhz8DsNJsxqTg1PbbLe0P8DG6iVxTaVSf6pdqYWAHMhy_-_3T7wjg
Monaco Editor Playground Code
Reproduction Steps
Actual (Problematic) Behavior
Font size changes twice. Instead of 13.2px (lets assume we are increasing font size and default value was 12px) it becomes 14.52px.
Expected Behavior
The font size does not change after instance re-creation.
Additional Context
It's easy to reproduce when you use any client router and monaco editor at the same time. In my case it's react-router. When I change font size, navigate away from the page and come back - font size changes one more time.
The text was updated successfully, but these errors were encountered: