diff --git a/src/commons/sagas/WorkspaceSaga.ts b/src/commons/sagas/WorkspaceSaga.ts index e0f4f00da7..ba91932000 100644 --- a/src/commons/sagas/WorkspaceSaga.ts +++ b/src/commons/sagas/WorkspaceSaga.ts @@ -1232,6 +1232,14 @@ export function* evalCode( yield* dumpDisplayBuffer(workspaceLocation, isStoriesBlock, storyEnv); if (!isStoriesBlock) { yield put(actions.evalInterpreterError(context.errors, workspaceLocation)); + // enable the CSE machine visualizer during errors + if (context.executionMethod === 'cse-machine' && needUpdateCse) { + yield put(actions.updateStepsTotal(context.runtime.envStepsTotal + 1, workspaceLocation)); + yield put(actions.toggleUpdateCse(false, workspaceLocation as any)); + yield put( + actions.updateBreakpointSteps(context.runtime.breakpointSteps, workspaceLocation) + ); + } } else { // Safe to use ! as storyEnv will be defined from above when we call from EVAL_STORY yield put(actions.evalStoryError(context.errors, storyEnv!)); diff --git a/src/commons/sideContent/__tests__/__snapshots__/SideContentCseMachine.tsx.snap b/src/commons/sideContent/__tests__/__snapshots__/SideContentCseMachine.tsx.snap index 2b891ca541..3ded2a0fb5 100644 --- a/src/commons/sideContent/__tests__/__snapshots__/SideContentCseMachine.tsx.snap +++ b/src/commons/sideContent/__tests__/__snapshots__/SideContentCseMachine.tsx.snap @@ -27,7 +27,7 @@ exports[`CSE Machine component renders correctly 1`] = ` className="bp5-slider-track" >
+ > +
+ 0 +
+
- 1 + 0
@@ -335,6 +346,7 @@ exports[`CSE Machine component renders correctly 1`] = `
+
// This comment is copied over from workspace saga props.setEditorHighlightedLines(0, segments); }, + // We shouldn't be able to move slider to a step number beyond the step limit isControlEmpty => { - this.setState({ stepLimitExceeded: !isControlEmpty && this.state.lastStep }); + this.setState({ stepLimitExceeded: false }); } ); } @@ -200,11 +203,11 @@ class SideContentCseMachineBase extends React.Component
@@ -296,6 +299,15 @@ class SideContentCseMachineBase extends React.Component
{' '} + {this.state.visualization && + this.props.machineOutput.length && + this.props.machineOutput[0].type === 'errors' ? ( + this.props.machineOutput.map((slice, index) => ( + + )) + ) : ( +
+ )} {this.state.visualization ? ( this.state.stepLimitExceeded ? (
}; private stepPrevious = () => { - if (this.state.value !== 1) { + if (this.state.value !== 0) { this.sliderShift(this.state.value - 1); this.sliderRelease(this.state.value - 1); } @@ -404,8 +416,8 @@ class SideContentCseMachineBase extends React.Component private stepFirst = () => { // Move to the first step - this.sliderShift(1); - this.sliderRelease(1); + this.sliderShift(0); + this.sliderRelease(0); }; private stepLast = (lastStepValue: number) => () => { @@ -435,8 +447,8 @@ class SideContentCseMachineBase extends React.Component return; } } - this.sliderShift(1); - this.sliderRelease(1); + this.sliderShift(0); + this.sliderRelease(0); }; } @@ -467,7 +479,8 @@ const mapStateToProps: MapStateToProps = ( stepsTotal: workspace.stepsTotal, currentStep: workspace.currentStep, breakpointSteps: workspace.breakpointSteps, - needCseUpdate: workspace.updateCse + needCseUpdate: workspace.updateCse, + machineOutput: workspace.output }; }; diff --git a/src/pages/playground/__tests__/__snapshots__/Playground.tsx.snap b/src/pages/playground/__tests__/__snapshots__/Playground.tsx.snap index 134723b2b5..250b5fc50b 100644 --- a/src/pages/playground/__tests__/__snapshots__/Playground.tsx.snap +++ b/src/pages/playground/__tests__/__snapshots__/Playground.tsx.snap @@ -732,36 +732,42 @@ and also the class="bp5-slider-track" >
+ > +
+ 0 +
+
- 1 + 0
@@ -951,6 +957,7 @@ and also the
+