@@ -12,6 +12,7 @@ import { getCodeMirror } from 'app/utils/codemirror';
1212import CodeMirror from 'codemirror' ;
1313import { listen } from 'codesandbox-api' ;
1414import * as React from 'react' ;
15+ import { debounce } from 'lodash-es' ;
1516import { withTheme } from 'styled-components' ;
1617// eslint-disable-next-line
1718import LinterWorker from 'worker-loader?publicPath=/&name=monaco-linter.[hash:8].worker.js!app/overmind/effects/vscode/LinterWorker/index' ;
@@ -54,6 +55,7 @@ class CodemirrorEditor extends React.Component<Props, State> implements Editor {
5455 this . settings = props . settings ;
5556
5657 this . codeSandboxListener = this . setupCodeSandboxListener ( ) ;
58+ this . resizeEditor = debounce ( this . resizeEditor , 30 ) ;
5759 }
5860
5961 setupCodeSandboxListener = ( ) => listen ( this . handleMessage ) ;
@@ -79,8 +81,7 @@ class CodemirrorEditor extends React.Component<Props, State> implements Editor {
7981 this . props . width !== nextProps . width ||
8082 this . props . height !== nextProps . height
8183 ) {
82- // eslint-disable-next-line no-unused-expressions
83- this . codemirror ?. refresh ( ) ;
84+ this . resizeEditor ( ) ;
8485 return true ;
8586 }
8687
@@ -111,6 +112,11 @@ class CodemirrorEditor extends React.Component<Props, State> implements Editor {
111112 } ) ;
112113 }
113114
115+ resizeEditor ( ) {
116+ // eslint-disable-next-line no-unused-expressions
117+ this . codemirror ?. refresh ( ) ;
118+ }
119+
114120 setErrors = ( errors : Array < ModuleError > ) => {
115121 const codeLines = this . codemirror . getValue ( ) . split ( '\n' ) ;
116122
0 commit comments