diff --git a/src/commons/sagas/WorkspaceSaga/helpers/evalCode.ts b/src/commons/sagas/WorkspaceSaga/helpers/evalCode.ts index 0b325bee2b..946f643146 100644 --- a/src/commons/sagas/WorkspaceSaga/helpers/evalCode.ts +++ b/src/commons/sagas/WorkspaceSaga/helpers/evalCode.ts @@ -161,7 +161,7 @@ export function* evalCode( const isLazy: boolean = context.variant === Variant.LAZY; const isWasm: boolean = context.variant === Variant.WASM; - const lastDebuggerResult = yield select( + let lastDebuggerResult = yield select( (state: OverallState) => state.workspaces[workspaceLocation].lastDebuggerResult ); @@ -215,17 +215,16 @@ export function* evalCode( yield call(showWarningMessage, 'Execution aborted', 750); return; } - if (paused) { yield put(actions.endDebuggerPause(workspaceLocation)); - yield put(actions.updateLastDebuggerResult(manualToggleDebugger(context))); + yield put(actions.updateLastDebuggerResult(manualToggleDebugger(context), workspaceLocation)); yield call(updateInspector, workspaceLocation); yield call(showWarningMessage, 'Execution paused', 750); return; } if (actionType === EVAL_EDITOR) { - yield put(actions.updateLastDebuggerResult(result)); + yield put(actions.updateLastDebuggerResult(result, workspaceLocation)); } // do not highlight for stories @@ -267,7 +266,7 @@ export function* evalCode( if (result.value === 'cut') { result.value = undefined; } - yield put(actions.updateLastNonDetResult(result)); + yield put(actions.updateLastNonDetResult(result, workspaceLocation)); } yield* dumpDisplayBuffer(workspaceLocation, isStoriesBlock, storyEnv); @@ -289,6 +288,9 @@ export function* evalCode( } } + lastDebuggerResult = yield select( + (state: OverallState) => state.workspaces[workspaceLocation].lastDebuggerResult + ); // For EVAL_EDITOR and EVAL_REPL, we send notification to workspace that a program has been evaluated if (actionType === EVAL_EDITOR || actionType === EVAL_REPL || actionType === DEBUG_RESUME) { if (context.errors.length > 0) { diff --git a/src/commons/sagas/WorkspaceSaga/index.ts b/src/commons/sagas/WorkspaceSaga/index.ts index d3e4f7ba60..6cd5760f9d 100644 --- a/src/commons/sagas/WorkspaceSaga/index.ts +++ b/src/commons/sagas/WorkspaceSaga/index.ts @@ -334,7 +334,7 @@ export default function* WorkspaceSaga(): SagaIterator { // TODO: Hardcoded to make use of the first editor tab. Rewrite after editor tabs are added. yield put(actions.setEditorHighlightedLines(workspaceLocation, 0, [])); context.runtime.break = false; - yield put(actions.updateLastDebuggerResult(undefined)); + yield put(actions.updateLastDebuggerResult(undefined, workspaceLocation)); }); yield takeEvery( diff --git a/src/commons/sideContent/__tests__/SideContentCseMachine.tsx b/src/commons/sideContent/__tests__/SideContentCseMachine.tsx index d1a9e77f1e..5507596621 100644 --- a/src/commons/sideContent/__tests__/SideContentCseMachine.tsx +++ b/src/commons/sideContent/__tests__/SideContentCseMachine.tsx @@ -26,7 +26,7 @@ test('CSE Machine sets visualization state and renders', async () => { expect(screen.queryAllByTestId('sa-cse-machine')).toHaveLength(0); const context = mockContext(); - runInContext('const hello="world"; debugger;', context); + await runInContext('const hello="world"; debugger;', context); act(() => visualizeCseMachine({ context })); expect(screen.queryAllByTestId('cse-machine-default-text')).toHaveLength(0); diff --git a/src/commons/workspace/WorkspaceActions.ts b/src/commons/workspace/WorkspaceActions.ts index 24cff2aff5..0968bab4fd 100644 --- a/src/commons/workspace/WorkspaceActions.ts +++ b/src/commons/workspace/WorkspaceActions.ts @@ -497,14 +497,14 @@ export const updateBreakpointSteps = createAction( export const updateLastDebuggerResult = createAction( UPDATE_LAST_DEBUGGER_RESULT, - (lastDebuggerResult: any) => ({ - payload: { lastDebuggerResult } + (lastDebuggerResult: any, workspaceLocation: WorkspaceLocation) => ({ + payload: { lastDebuggerResult, workspaceLocation } }) ); export const updateLastNonDetResult = createAction( UPDATE_LAST_NON_DET_RESULT, - (lastNonDetResult: Result) => ({ - payload: { lastNonDetResult } + (lastNonDetResult: Result, workspaceLocation: WorkspaceLocation) => ({ + payload: { lastNonDetResult, workspaceLocation } }) );