Skip to content

Commit 147da87

Browse files
authored
Messages to handle breakpoints in vscode (#3249)
1 parent 2135803 commit 147da87

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

src/commons/application/Application.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ const Application: React.FC = () => {
138138
case MessageTypeNames.AssessmentAnswer:
139139
dispatch(SessionActions.submitAnswer(message.questionId, message.answer));
140140
break;
141+
case MessageTypeNames.SetEditorBreakpoints:
142+
dispatch(
143+
WorkspaceActions.setEditorBreakpoint(
144+
message.workspaceLocation,
145+
0,
146+
message.newBreakpoints
147+
)
148+
);
149+
break;
141150
}
142151
});
143152
// eslint-disable-next-line react-hooks/exhaustive-deps

src/commons/assessmentWorkspace/AssessmentWorkspace.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,16 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
412412
case QuestionTypes.programming || QuestionTypes.voting:
413413
const prepend = question.prepend;
414414
const code = question.answer ?? question.solutionTemplate;
415+
const breakpoints = editorTabs[0]?.breakpoints ?? [];
415416
sendToWebview(
416417
Messages.NewEditor(
417418
workspaceLocation,
418419
`assessment${assessment.id}`,
419420
props.questionId,
420421
chapter,
421422
prepend,
422-
code
423+
code,
424+
breakpoints
423425
)
424426
);
425427
break;
@@ -449,14 +451,16 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
449451
// TODO: Hardcoded to make use of the first editor tab. Refactoring is needed for this workspace to enable Folder mode.
450452
handleEditorValueChange(0, answer);
451453
// Hacky way to view the editor, might cause issues
454+
const breakpoints = editorTabs[0]?.breakpoints ?? [];
452455
sendToWebview(
453456
Messages.NewEditor(
454457
workspaceLocation,
455458
`submission${_submissionId}`,
456459
questionId,
457460
question.library.chapter,
458461
'',
459-
answer
462+
answer,
463+
breakpoints
460464
)
461465
);
462466
//

src/features/vscode/messages.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ const Messages = createMessages({
3333
questionId: number,
3434
chapter: number,
3535
prepend: string,
36-
initialCode: string
36+
initialCode: string,
37+
breakpoints: string[]
3738
) => ({
3839
workspaceLocation,
3940
assessmentName,
4041
questionId,
4142
chapter,
4243
prepend,
43-
initialCode
44+
initialCode,
45+
breakpoints
4446
}),
4547
Text: (workspaceLocation: VscWorkspaceLocation, code: string) => ({
4648
workspaceLocation,
@@ -99,7 +101,11 @@ const Messages = createMessages({
99101
questionId,
100102
answer
101103
}),
102-
LoginWithBrowser: (route: string) => ({ route })
104+
LoginWithBrowser: (route: string) => ({ route }),
105+
SetEditorBreakpoints: (workspaceLocation: VscWorkspaceLocation, newBreakpoints: string[]) => ({
106+
workspaceLocation,
107+
newBreakpoints
108+
})
103109
});
104110

105111
export default Messages;

src/pages/playground/Playground.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,16 @@ const Playground: React.FC<PlaygroundProps> = props => {
381381
return;
382382
}
383383
const initialCode = editorTabs[0]?.value ?? '';
384+
const breakpoints = editorTabs[0]?.breakpoints ?? [];
384385
sendToWebview(
385386
Messages.NewEditor(
386387
workspaceLocation,
387388
'playground',
388389
1,
389390
playgroundSourceChapter,
390391
'',
391-
initialCode
392+
initialCode,
393+
breakpoints
392394
)
393395
);
394396
// We don't want to re-send this message even when the variables change

0 commit comments

Comments
 (0)