1+ const maxAllowedHeight = 600 ;
2+
13function mymonaco ( config ) {
24 require . config ( { paths : { 'vs' : 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.39.0/min/vs' } } ) ;
35 require ( [ 'vs/editor/editor.main' ] , initializeEditors ) ;
@@ -6,9 +8,7 @@ function mymonaco(config) {
68 const right_container_id = config . rcid ; /*'right-container';*/
79 const leftContainer = document . getElementById ( left_container_id ) ;
810 const rightContainer = document . getElementById ( right_container_id ) ;
9- let isLayoutUpdating = false ;
10- let lastUpdateDebounce = Date . now ( ) ;
11- let isInitialLayout = true ; // Flag to track the initial layout
11+
1212 Promise . all ( [
1313 Promise . resolve ( monaco . editor . create ( leftContainer , getEditorOptions ( config , config . left . content ) ) ) ,
1414 Promise . resolve ( monaco . editor . create ( rightContainer , getEditorOptions ( config , config . right . content ) ) )
@@ -41,23 +41,13 @@ function mymonaco(config) {
4141
4242 if ( config . spv === true ) {
4343 const updateEditorsLayout = ( ) => {
44- isInitialLayout = false ; // Disable the initial layout update flag
45- if ( Date . now ( ) - lastUpdateDebounce > 2000 && ! isLayoutUpdating )
46- return ; // Debounce layout updates
47- lastUpdateDebounce = Date . now ( ) ;
48- isLayoutUpdating = true ;
4944 const leftHeight = leftEditor . getContentHeight ( ) ;
5045 const rightHeight = rightEditor . getContentHeight ( ) ;
51- const editorHeight = Math . max ( leftHeight , rightHeight ) ;
52-
53- if ( isInitialLayout ) {
54- leftContainer . style . height = 500 + 'px' ;
55- rightContainer . style . height = 500 + 'px' ;
56- }
57- else {
58- leftContainer . style . height = leftHeight + 'px' ;
59- rightContainer . style . height = rightHeight + 'px' ;
60- }
46+ let maxHeight = Math . max ( leftHeight , rightHeight ) ;
47+ const editorHeight = maxHeight > maxAllowedHeight ? maxAllowedHeight : maxHeight ;
48+ console . log ( editorHeight ) ;
49+ leftContainer . style . height = editorHeight + 'px' ;
50+ rightContainer . style . height = editorHeight + 'px' ;
6151 leftEditor . layout ( ) ;
6252 rightEditor . layout ( ) ;
6353 } ;
0 commit comments