diff --git a/src/frontend/apis/index.js b/src/frontend/apis/index.js
index 93a0e5d484b566fc9ff568c2ba5b751b2ac70a90..be130ecbce798363b04ddc7a661b827f01ce62c8 100644
--- a/src/frontend/apis/index.js
+++ b/src/frontend/apis/index.js
@@ -74,7 +74,7 @@ const TracerApi = {
if (jsWorker) jsWorker.terminate();
jsWorker = new Worker('/api/tracers/js');
jsWorker.onmessage = e => resolve(e.data);
- jsWorker.onerror = reject;
+ jsWorker.onerror = err => reject({ status: 500, err });
jsWorker.postMessage(code);
}),
java: POST('/tracers/java'),
diff --git a/src/frontend/components/App/index.jsx b/src/frontend/components/App/index.jsx
index 22fce7b14e28c1774e04cea8a96aca65bc90dbd6..fe0c839418269ac1e3af13dedfaee495de7bf62a 100644
--- a/src/frontend/components/App/index.jsx
+++ b/src/frontend/components/App/index.jsx
@@ -183,7 +183,7 @@ class App extends React.Component {
render() {
const { navigatorOpened, workspaceWeights, viewerTabIndex, editingFileName } = this.state;
- const { files } = this.props.current;
+ const { titles, files } = this.props.current;
const readmeFile = files.find(file => file.name === 'README.md');
const editorTabIndex = files.findIndex(file => file.name === editingFileName);
@@ -208,7 +208,7 @@ class App extends React.Component {
onChangeTabIndex={tabIndex => this.handleChangeEditorTabIndex(tabIndex)}>
{
files.map(file => (
-
+
))
}
diff --git a/src/frontend/components/CodeEditor/index.jsx b/src/frontend/components/CodeEditor/index.jsx
index 99155f9e64d64b6829d0f0fddcdd05d18aef3721..0733de71a7d9f2250047e1a202fdcc00958f8154 100644
--- a/src/frontend/components/CodeEditor/index.jsx
+++ b/src/frontend/components/CodeEditor/index.jsx
@@ -28,7 +28,7 @@ class CodeEditor extends React.Component {
componentDidMount() {
const { file } = this.props;
- tracerManager.setFile(file);
+ tracerManager.setFile(file, true);
tracerManager.setOnUpdateLineIndicator(lineIndicator => this.setState({ lineMarker: this.createLineMarker(lineIndicator) }));
}
@@ -36,7 +36,7 @@ class CodeEditor extends React.Component {
componentWillReceiveProps(nextProps) {
const { file } = nextProps;
if (file !== this.props.file) {
- tracerManager.setFile(file);
+ tracerManager.setFile(file, extension(file.name) === 'js');
}
}
diff --git a/src/frontend/core/tracerManager.jsx b/src/frontend/core/tracerManager.jsx
index d8223a231cc2a2424a6758c86efcdc75dff9dfb2..942db5c58c797224a1a3df91291acf80f39d0b90 100644
--- a/src/frontend/core/tracerManager.jsx
+++ b/src/frontend/core/tracerManager.jsx
@@ -61,9 +61,9 @@ class TracerManager {
if (this.onUpdateLineIndicator) this.onUpdateLineIndicator(lineIndicator);
}
- setFile(file) {
+ setFile(file, initialRun) {
this.file = file;
- if (extension(file.name) === 'js') this.runInitial();
+ if (initialRun) this.runInitial();
}
reset(traces = []) {
@@ -157,7 +157,6 @@ class TracerManager {
const ext = extension(name);
if (ext in TracerApi) {
return TracerApi[ext]({ code: content })
- .then(traces => this.reset(traces))
.catch(e => {
throw e.err;
});
@@ -167,23 +166,25 @@ class TracerManager {
}
runInitial() {
+ this.reset();
+ this.render();
this.execute()
- .then(() => this.applyTraceChunk())
- .catch(() => {
- this.reset();
- this.render();
+ .then(traces => {
+ this.reset(traces);
+ this.applyTraceChunk();
});
}
run() {
+ this.reset();
+ this.render();
this.execute()
- .then(() => {
+ .then(traces => {
+ this.reset(traces);
this.resume();
this.setStarted(true);
})
.catch(error => {
- this.reset();
- this.render();
this.handleError(error);
});
}