File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,31 @@ export class Editor {
200200 this . onChangeCallback = callback ;
201201 }
202202
203- reset ( prepend : string , initialCode : string ) {
203+ async save ( ) {
204+ this . log ( `EXTENSION: Editor's save called` ) ;
205+ if ( ! this . editor ) {
206+ this . log ( `EXTENSION: Editor is not defined, cannot save` ) ;
207+ return ;
208+ }
209+ const text = this . editor . document . getText ( ) ;
210+ if ( text === "" ) {
211+ this . log ( `EXTENSION: Editor's code is empty, not saving` ) ;
212+ return ;
213+ }
214+ await vscode . workspace . fs . writeFile (
215+ vscode . Uri . file ( this . editor . document . fileName ) ,
216+ new TextEncoder ( ) . encode ( text ) ,
217+ ) ;
218+ this . log ( `EXTENSION: Editor's code saved successfully` ) ;
219+ //?: Send the code to the frontend - if needed
220+ // const message = Messages.Text(
221+ // this.workspaceLocation,
222+ // text,
223+ // );
224+ // sendToFrontendWrapped(message);
225+ }
226+
227+ async reset ( prepend : string , initialCode : string ) {
204228 this . log ( `EXTENSION: Editor's reset called` ) ;
205229 this . replace (
206230 prepend !== ""
@@ -213,5 +237,7 @@ export class Editor {
213237 : initialCode ,
214238 "reset" ,
215239 ) ;
240+ await this . save ( ) ;
241+ this . log ( `EXTENSION: Editor's code reset successfully` ) ;
216242 }
217243}
You can’t perform that action at this time.
0 commit comments