@@ -375,7 +375,7 @@ export class ViewLines extends ViewLayer {
375375 throw new Error ( 'Not supported' ) ;
376376 }
377377
378- public renderText ( linesViewportData :editorCommon . ViewLinesViewportData ) : void {
378+ public renderText ( linesViewportData :editorCommon . ViewLinesViewportData , onAfterLinesRendered : ( ) => void ) : void {
379379 if ( ! this . shouldRender ( ) ) {
380380 throw new Error ( 'I did not ask to render!' ) ;
381381 }
@@ -387,7 +387,10 @@ export class ViewLines extends ViewLayer {
387387 this . domNode . setWidth ( this . _layoutProvider . getScrollWidth ( ) ) ;
388388 this . domNode . setHeight ( Math . min ( this . _layoutProvider . getTotalHeight ( ) , 1000000 ) ) ;
389389
390- // (2) compute horizontal scroll position:
390+ // (2) execute DOM writing that forces sync layout (e.g. textArea manipulation)
391+ onAfterLinesRendered ( ) ;
392+
393+ // (3) compute horizontal scroll position:
391394 // - this must happen after the lines are in the DOM since it might need a line that rendered just now
392395 // - it might change `scrollWidth` and `scrollLeft`
393396 if ( this . _lastCursorRevealRangeHorizontallyEvent ) {
@@ -410,6 +413,7 @@ export class ViewLines extends ViewLayer {
410413 this . _layoutProvider . setScrollLeft ( newScrollLeft . scrollLeft ) ;
411414 }
412415
416+ // (4) handle scrolling
413417 let somethingChanged = false ;
414418 if ( browser . canUseTranslate3d ) {
415419 var transform = 'translate3d(' + - this . _layoutProvider . getScrollLeft ( ) + 'px, ' + linesViewportData . visibleRangesDeltaTop + 'px, 0px)' ;
@@ -418,6 +422,8 @@ export class ViewLines extends ViewLayer {
418422 somethingChanged = StyleMutator . setTop ( < HTMLElement > this . domNode . domNode . parentNode , linesViewportData . visibleRangesDeltaTop ) || somethingChanged ; // TODO@Alex
419423 somethingChanged = StyleMutator . setLeft ( < HTMLElement > this . domNode . domNode . parentNode , - this . _layoutProvider . getScrollLeft ( ) ) || somethingChanged ; // TODO@Alex
420424 }
425+
426+ // (5) reset cached client rect left if scrolling changed something
421427 if ( somethingChanged ) {
422428 this . _lastRenderedData . resetDomNodeClientRectLeft ( ) ;
423429 }
0 commit comments