Hacky runtime error highlight working
This commit is contained in:
parent
1bb0efdac8
commit
b5f9879c44
2 changed files with 21 additions and 3 deletions
|
@ -118,8 +118,6 @@ class Editor extends React.Component {
|
||||||
this._cm.getWrapperElement().style['font-size'] = `${this.props.fontSize}px`;
|
this._cm.getWrapperElement().style['font-size'] = `${this.props.fontSize}px`;
|
||||||
this._cm.setOption('indentWithTabs', this.props.isTabIndent);
|
this._cm.setOption('indentWithTabs', this.props.isTabIndent);
|
||||||
this._cm.setOption('tabSize', this.props.indentationAmount);
|
this._cm.setOption('tabSize', this.props.indentationAmount);
|
||||||
|
|
||||||
this._cm.addLineClass(1, null, 'line-runtime-error');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUpdate(nextProps) {
|
componentWillUpdate(nextProps) {
|
||||||
|
@ -155,6 +153,20 @@ class Editor extends React.Component {
|
||||||
if (this.props.theme !== prevProps.theme) {
|
if (this.props.theme !== prevProps.theme) {
|
||||||
this._cm.setOption('theme', `p5-${this.props.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() {
|
componentWillUnmount() {
|
||||||
|
@ -290,6 +302,10 @@ Editor.propTypes = {
|
||||||
message: PropTypes.string.isRequired,
|
message: PropTypes.string.isRequired,
|
||||||
id: PropTypes.number.isRequired
|
id: PropTypes.number.isRequired
|
||||||
})).isRequired,
|
})).isRequired,
|
||||||
|
consoleEvents: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
method: PropTypes.string.isRequired,
|
||||||
|
args: PropTypes.arrayOf(PropTypes.string)
|
||||||
|
})),
|
||||||
updateLintMessage: PropTypes.func.isRequired,
|
updateLintMessage: PropTypes.func.isRequired,
|
||||||
clearLintMessage: PropTypes.func.isRequired,
|
clearLintMessage: PropTypes.func.isRequired,
|
||||||
indentationAmount: PropTypes.number.isRequired,
|
indentationAmount: PropTypes.number.isRequired,
|
||||||
|
@ -325,7 +341,8 @@ Editor.propTypes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
Editor.defaultProps = {
|
Editor.defaultProps = {
|
||||||
isUserOwner: false
|
isUserOwner: false,
|
||||||
|
consoleEvents: []
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Editor;
|
export default Editor;
|
||||||
|
|
|
@ -341,6 +341,7 @@ class IDEView extends React.Component {
|
||||||
collapseSidebar={this.props.collapseSidebar}
|
collapseSidebar={this.props.collapseSidebar}
|
||||||
isUserOwner={this.isUserOwner()}
|
isUserOwner={this.isUserOwner()}
|
||||||
clearConsole={this.props.clearConsole}
|
clearConsole={this.props.clearConsole}
|
||||||
|
consoleEvents={this.props.console}
|
||||||
/>
|
/>
|
||||||
<Console
|
<Console
|
||||||
consoleEvents={this.props.console}
|
consoleEvents={this.props.console}
|
||||||
|
|
Loading…
Reference in a new issue