@@ -115,7 +115,6 @@ class Editor extends React.Component {
115115 styleSelectedText : true ,
116116 lint : {
117117 onUpdateLinting : ( annotations ) => {
118- this . props . hideRuntimeErrorWarning ( ) ;
119118 this . updateLintingMessageAccessibility ( annotations ) ;
120119 } ,
121120 options : {
@@ -159,6 +158,7 @@ class Editor extends React.Component {
159158 'change' ,
160159 debounce ( ( ) => {
161160 this . props . setUnsavedChanges ( true ) ;
161+ this . props . hideRuntimeErrorWarning ( ) ;
162162 this . props . updateFileContent ( this . props . file . id , this . _cm . getValue ( ) ) ;
163163 if ( this . props . autorefresh && this . props . isPlaying ) {
164164 this . props . clearConsole ( ) ;
@@ -246,12 +246,6 @@ class Editor extends React.Component {
246246 ) ;
247247 }
248248
249- if ( prevProps . consoleEvents !== this . props . consoleEvents ) {
250- this . props . showRuntimeErrorWarning ( ) ;
251- }
252- for ( let i = 0 ; i < this . _cm . lineCount ( ) ; i += 1 ) {
253- this . _cm . removeLineClass ( i , 'background' , 'line-runtime-error' ) ;
254- }
255249 if ( this . props . runtimeErrorWarningVisible ) {
256250 this . props . consoleEvents . forEach ( ( consoleEvent ) => {
257251 if ( consoleEvent . method === 'error' ) {
@@ -261,26 +255,24 @@ class Editor extends React.Component {
261255 consoleEvent . data [ 0 ] . indexOf &&
262256 consoleEvent . data [ 0 ] . indexOf ( ')' ) > - 1
263257 ) {
264- const n = consoleEvent . data [ 0 ] . replace ( ')' , '' ) . split ( ' ' ) ;
265- const lineNumber = parseInt ( n [ n . length - 1 ] , 10 ) - 1 ;
266- const { source } = consoleEvent ;
267- const fileName = this . props . file . name ;
268- const errorFromJavaScriptFile = `${ source } .js` === fileName ;
269- const errorFromIndexHTML =
270- source === fileName && fileName === 'index.html' ;
271- if (
272- ! Number . isNaN ( lineNumber ) &&
273- ( errorFromJavaScriptFile || errorFromIndexHTML )
274- ) {
275- this . _cm . addLineClass (
276- lineNumber ,
277- 'background' ,
278- 'line-runtime-error'
279- ) ;
280- }
258+ const sourceAndLoc = consoleEvent . data [ 0 ]
259+ . split ( '\n' ) [ 1 ]
260+ . split ( '(' ) [ 1 ]
261+ . split ( ')' ) [ 0 ] ;
262+ const [ source , line , column ] = sourceAndLoc . split ( ':' ) ;
263+ const lineNumber = parseInt ( line , 10 ) - 1 ;
264+ this . _cm . addLineClass (
265+ lineNumber ,
266+ 'background' ,
267+ 'line-runtime-error'
268+ ) ;
281269 }
282270 }
283271 } ) ;
272+ } else {
273+ for ( let i = 0 ; i < this . _cm . lineCount ( ) ; i += 1 ) {
274+ this . _cm . removeLineClass ( i , 'background' , 'line-runtime-error' ) ;
275+ }
284276 }
285277 }
286278
@@ -440,7 +432,7 @@ Editor.propTypes = {
440432 method : PropTypes . string . isRequired ,
441433 args : PropTypes . arrayOf ( PropTypes . string )
442434 } )
443- ) ,
435+ ) . isRequired ,
444436 updateLintMessage : PropTypes . func . isRequired ,
445437 clearLintMessage : PropTypes . func . isRequired ,
446438 updateFileContent : PropTypes . func . isRequired ,
@@ -471,17 +463,13 @@ Editor.propTypes = {
471463 expandSidebar : PropTypes . func . isRequired ,
472464 isUserOwner : PropTypes . bool . isRequired ,
473465 clearConsole : PropTypes . func . isRequired ,
474- showRuntimeErrorWarning : PropTypes . func . isRequired ,
466+ // showRuntimeErrorWarning: PropTypes.func.isRequired,
475467 hideRuntimeErrorWarning : PropTypes . func . isRequired ,
476468 runtimeErrorWarningVisible : PropTypes . bool . isRequired ,
477469 provideController : PropTypes . func . isRequired ,
478470 t : PropTypes . func . isRequired
479471} ;
480472
481- Editor . defaultProps = {
482- consoleEvents : [ ]
483- } ;
484-
485473function mapStateToProps ( state ) {
486474 return {
487475 files : state . files ,
@@ -496,7 +484,7 @@ function mapStateToProps(state) {
496484 user : state . user ,
497485 project : state . project ,
498486 toast : state . toast ,
499- console : state . console ,
487+ consoleEvents : state . console ,
500488
501489 ...state . preferences ,
502490 ...state . ide ,
0 commit comments