File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -199,4 +199,19 @@ export class Editor {
199
199
) {
200
200
this . onChangeCallback = callback ;
201
201
}
202
+
203
+ reset ( prepend : string , initialCode : string ) {
204
+ this . log ( `EXTENSION: Editor's reset called` ) ;
205
+ this . replace (
206
+ prepend !== ""
207
+ ? [
208
+ "// PREPEND -- DO NOT EDIT" ,
209
+ prepend ,
210
+ "// END PREPEND" ,
211
+ initialCode ,
212
+ ] . join ( "\n" )
213
+ : initialCode ,
214
+ "reset" ,
215
+ ) ;
216
+ }
202
217
}
Original file line number Diff line number Diff line change @@ -110,7 +110,12 @@ export class MessageHandler {
110
110
sendToFrontend ( this . panel , msg ) ;
111
111
break ;
112
112
}
113
-
113
+ case MessageTypeNames . ResetEditor :
114
+ if ( this . activeEditor ) {
115
+ this . activeEditor . reset ( "" , message . initialCode ) ;
116
+ this . panel ?. reveal ( vscode . ViewColumn . Two ) ;
117
+ }
118
+ break ;
114
119
case MessageTypeNames . NewEditor :
115
120
this . activeEditor = await Editor . create (
116
121
message . workspaceLocation ,
Original file line number Diff line number Diff line change @@ -48,6 +48,13 @@ const Messages = createMessages({
48
48
EvalEditor : ( workspaceLocation : VscWorkspaceLocation ) => ( {
49
49
workspaceLocation : workspaceLocation ,
50
50
} ) ,
51
+ ResetEditor : (
52
+ workspaceLocation : VscWorkspaceLocation ,
53
+ initialCode : string ,
54
+ ) => ( {
55
+ workspaceLocation,
56
+ initialCode,
57
+ } ) ,
51
58
NotifyAssessmentsOverview : (
52
59
assessmentOverviews : VscAssessmentOverview [ ] ,
53
60
courseId : number ,
You can’t perform that action at this time.
0 commit comments