@@ -188,8 +188,11 @@ export class MonacoEditor extends React.Component<IMonacoEditorProps, IMonacoEdi
188
188
this . subscriptions . push (
189
189
editor . onDidLayoutChange ( ( ) => {
190
190
this . windowResized ( ) ;
191
- // Also recompute our visible line heights
191
+ // Recompute visible line tops
192
192
this . debouncedComputeLineTops ( ) ;
193
+
194
+ // A layout change may be because of a new line
195
+ this . throttledScrollCurrentPosition ( editor ) ;
193
196
} )
194
197
) ;
195
198
@@ -243,7 +246,9 @@ export class MonacoEditor extends React.Component<IMonacoEditorProps, IMonacoEdi
243
246
this . subscriptions . push (
244
247
editor . onDidChangeCursorPosition ( ( ) => {
245
248
this . throttledUpdateWidgetPosition ( ) ;
246
- this . throttledScrollCurrentPosition ( editor ) ;
249
+
250
+ // Do this after the cursor changes so the text has time to appear
251
+ setTimeout ( ( ) => this . throttledScrollCurrentPosition ( editor ) , 0 ) ;
247
252
} )
248
253
) ;
249
254
@@ -643,14 +648,12 @@ export class MonacoEditor extends React.Component<IMonacoEditorProps, IMonacoEdi
643
648
const editorDomNode = this . state . editor . getDomNode ( ) ;
644
649
if ( editorDomNode ) {
645
650
const container = editorDomNode . getElementsByClassName ( 'view-lines' ) [ 0 ] as HTMLElement ;
646
- const lineHeightPx =
647
- container . firstChild && ( container . firstChild as HTMLElement ) . style . height
648
- ? ( container . firstChild as HTMLElement ) . style . height
649
- : `${ LINE_HEIGHT } px` ;
650
- MonacoEditor . lineHeight =
651
- lineHeightPx && lineHeightPx . endsWith ( 'px' )
652
- ? parseInt ( lineHeightPx . substr ( 0 , lineHeightPx . length - 2 ) , 10 )
653
- : LINE_HEIGHT ;
651
+ if ( container . firstChild && ( container . firstChild as HTMLElement ) . style . height ) {
652
+ const lineHeightPx = ( container . firstChild as HTMLElement ) . style . height ;
653
+ MonacoEditor . lineHeight = parseInt ( lineHeightPx , 10 ) ;
654
+ } else {
655
+ return LINE_HEIGHT ;
656
+ }
654
657
}
655
658
}
656
659
return MonacoEditor . lineHeight ;
0 commit comments