Skip to content

Commit 72873e6

Browse files
FIX: CSE machine does not trigger (#2876)
* Initial fix * Fix test
1 parent 05bb216 commit 72873e6

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/commons/sagas/WorkspaceSaga/helpers/evalCode.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export function* evalCode(
161161
const isLazy: boolean = context.variant === Variant.LAZY;
162162
const isWasm: boolean = context.variant === Variant.WASM;
163163

164-
const lastDebuggerResult = yield select(
164+
let lastDebuggerResult = yield select(
165165
(state: OverallState) => state.workspaces[workspaceLocation].lastDebuggerResult
166166
);
167167

@@ -215,17 +215,16 @@ export function* evalCode(
215215
yield call(showWarningMessage, 'Execution aborted', 750);
216216
return;
217217
}
218-
219218
if (paused) {
220219
yield put(actions.endDebuggerPause(workspaceLocation));
221-
yield put(actions.updateLastDebuggerResult(manualToggleDebugger(context)));
220+
yield put(actions.updateLastDebuggerResult(manualToggleDebugger(context), workspaceLocation));
222221
yield call(updateInspector, workspaceLocation);
223222
yield call(showWarningMessage, 'Execution paused', 750);
224223
return;
225224
}
226225

227226
if (actionType === EVAL_EDITOR) {
228-
yield put(actions.updateLastDebuggerResult(result));
227+
yield put(actions.updateLastDebuggerResult(result, workspaceLocation));
229228
}
230229

231230
// do not highlight for stories
@@ -267,7 +266,7 @@ export function* evalCode(
267266
if (result.value === 'cut') {
268267
result.value = undefined;
269268
}
270-
yield put(actions.updateLastNonDetResult(result));
269+
yield put(actions.updateLastNonDetResult(result, workspaceLocation));
271270
}
272271

273272
yield* dumpDisplayBuffer(workspaceLocation, isStoriesBlock, storyEnv);
@@ -289,6 +288,9 @@ export function* evalCode(
289288
}
290289
}
291290

291+
lastDebuggerResult = yield select(
292+
(state: OverallState) => state.workspaces[workspaceLocation].lastDebuggerResult
293+
);
292294
// For EVAL_EDITOR and EVAL_REPL, we send notification to workspace that a program has been evaluated
293295
if (actionType === EVAL_EDITOR || actionType === EVAL_REPL || actionType === DEBUG_RESUME) {
294296
if (context.errors.length > 0) {

src/commons/sagas/WorkspaceSaga/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export default function* WorkspaceSaga(): SagaIterator {
334334
// TODO: Hardcoded to make use of the first editor tab. Rewrite after editor tabs are added.
335335
yield put(actions.setEditorHighlightedLines(workspaceLocation, 0, []));
336336
context.runtime.break = false;
337-
yield put(actions.updateLastDebuggerResult(undefined));
337+
yield put(actions.updateLastDebuggerResult(undefined, workspaceLocation));
338338
});
339339

340340
yield takeEvery(

src/commons/sideContent/__tests__/SideContentCseMachine.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test('CSE Machine sets visualization state and renders', async () => {
2626
expect(screen.queryAllByTestId('sa-cse-machine')).toHaveLength(0);
2727

2828
const context = mockContext();
29-
runInContext('const hello="world"; debugger;', context);
29+
await runInContext('const hello="world"; debugger;', context);
3030
act(() => visualizeCseMachine({ context }));
3131

3232
expect(screen.queryAllByTestId('cse-machine-default-text')).toHaveLength(0);

src/commons/workspace/WorkspaceActions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,14 @@ export const updateBreakpointSteps = createAction(
497497

498498
export const updateLastDebuggerResult = createAction(
499499
UPDATE_LAST_DEBUGGER_RESULT,
500-
(lastDebuggerResult: any) => ({
501-
payload: { lastDebuggerResult }
500+
(lastDebuggerResult: any, workspaceLocation: WorkspaceLocation) => ({
501+
payload: { lastDebuggerResult, workspaceLocation }
502502
})
503503
);
504504

505505
export const updateLastNonDetResult = createAction(
506506
UPDATE_LAST_NON_DET_RESULT,
507-
(lastNonDetResult: Result) => ({
508-
payload: { lastNonDetResult }
507+
(lastNonDetResult: Result, workspaceLocation: WorkspaceLocation) => ({
508+
payload: { lastNonDetResult, workspaceLocation }
509509
})
510510
);

0 commit comments

Comments
 (0)