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 {
199199 ) {
200200 this . onChangeCallback = callback ;
201201 }
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+ }
202217}
Original file line number Diff line number Diff line change @@ -110,7 +110,12 @@ export class MessageHandler {
110110 sendToFrontend ( this . panel , msg ) ;
111111 break ;
112112 }
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 ;
114119 case MessageTypeNames . NewEditor :
115120 this . activeEditor = await Editor . create (
116121 message . workspaceLocation ,
Original file line number Diff line number Diff line change @@ -48,6 +48,13 @@ const Messages = createMessages({
4848 EvalEditor : ( workspaceLocation : VscWorkspaceLocation ) => ( {
4949 workspaceLocation : workspaceLocation ,
5050 } ) ,
51+ ResetEditor : (
52+ workspaceLocation : VscWorkspaceLocation ,
53+ initialCode : string ,
54+ ) => ( {
55+ workspaceLocation,
56+ initialCode,
57+ } ) ,
5158 NotifyAssessmentsOverview : (
5259 assessmentOverviews : VscAssessmentOverview [ ] ,
5360 courseId : number ,
You can’t perform that action at this time.
0 commit comments