@@ -783,12 +783,7 @@ function checkEditorStyle() {
783783 if ( scrollbarStyle == 'overlay' || currentMode == modeType . both ) {
784784 ui . area . codemirrorScroll . css ( 'height' , desireHeight + 'px' ) ;
785785 ui . area . codemirrorScroll . css ( 'min-height' , '' ) ;
786- // workaround simple scroll bar knob
787- // will get wrong position when editor height changed
788- var scrollInfo = editor . getScrollInfo ( ) ;
789- preventSyncScroll = true ;
790- editor . scrollTo ( null , scrollInfo . top - 1 ) ;
791- editor . scrollTo ( null , scrollInfo . top ) ;
786+ checkEditorScrollbar ( ) ;
792787 } else if ( scrollbarStyle == 'native' ) {
793788 ui . area . codemirrorScroll . css ( 'height' , '' ) ;
794789 ui . area . codemirrorScroll . css ( 'min-height' , desireHeight + 'px' ) ;
@@ -806,6 +801,15 @@ function checkEditorStyle() {
806801 } ) ;
807802}
808803
804+ function checkEditorScrollbar ( ) {
805+ // workaround simple scroll bar knob
806+ // will get wrong position when editor height changed
807+ var scrollInfo = editor . getScrollInfo ( ) ;
808+ preventSyncScroll = true ;
809+ editor . scrollTo ( null , scrollInfo . top - 1 ) ;
810+ editor . scrollTo ( null , scrollInfo . top ) ;
811+ }
812+
809813function checkTocStyle ( ) {
810814 //toc right
811815 var paddingRight = parseFloat ( ui . area . markdown . css ( 'padding-right' ) ) ;
@@ -2216,6 +2220,7 @@ editor.on('changes', function (cm, changes) {
22162220 viewportMargin = newViewportMargin ;
22172221 windowResize ( ) ;
22182222 }
2223+ checkEditorScrollbar ( ) ;
22192224} ) ;
22202225editor . on ( 'focus' , function ( cm ) {
22212226 for ( var i = 0 ; i < onlineUsers . length ; i ++ ) {
0 commit comments