diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index 82ca2200..3091158b 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -118,8 +118,6 @@ class Editor extends React.Component { this._cm.getWrapperElement().style['font-size'] = `${this.props.fontSize}px`; this._cm.setOption('indentWithTabs', this.props.isTabIndent); this._cm.setOption('tabSize', this.props.indentationAmount); - - this._cm.addLineClass(1, null, 'line-runtime-error'); } componentWillUpdate(nextProps) { @@ -155,6 +153,20 @@ class Editor extends React.Component { if (this.props.theme !== prevProps.theme) { this._cm.setOption('theme', `p5-${this.props.theme}`); } + for (let i = 0; i < 1000; i += 1) { + this._cm.removeLineClass(i, 'background', 'line-runtime-error'); + } + this.props.consoleEvents.forEach((consoleEvent) => { + if (consoleEvent.method === 'error') { + console.log(consoleEvent.arguments); + console.log(consoleEvent.source); + + const n = consoleEvent.arguments.replace(')', '').split(' '); + const lineNumber = parseInt(n[n.length - 1], 10) - 1; + console.log(lineNumber); + this._cm.addLineClass(lineNumber, 'background', 'line-runtime-error'); + } + }); } componentWillUnmount() { @@ -290,6 +302,10 @@ Editor.propTypes = { message: PropTypes.string.isRequired, id: PropTypes.number.isRequired })).isRequired, + consoleEvents: PropTypes.arrayOf(PropTypes.shape({ + method: PropTypes.string.isRequired, + args: PropTypes.arrayOf(PropTypes.string) + })), updateLintMessage: PropTypes.func.isRequired, clearLintMessage: PropTypes.func.isRequired, indentationAmount: PropTypes.number.isRequired, @@ -325,7 +341,8 @@ Editor.propTypes = { }; Editor.defaultProps = { - isUserOwner: false + isUserOwner: false, + consoleEvents: [] }; export default Editor; diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index ca6d22d3..62ec3269 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -341,6 +341,7 @@ class IDEView extends React.Component { collapseSidebar={this.props.collapseSidebar} isUserOwner={this.isUserOwner()} clearConsole={this.props.clearConsole} + consoleEvents={this.props.console} />