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 @@ -197,7 +197,31 @@ export class Editor {
197
197
this . onChangeCallback = callback ;
198
198
}
199
199
200
- reset ( prepend : string , initialCode : string ) {
200
+ async save ( ) {
201
+ this . log ( `EXTENSION: Editor's save called` ) ;
202
+ if ( ! this . editor ) {
203
+ this . log ( `EXTENSION: Editor is not defined, cannot save` ) ;
204
+ return ;
205
+ }
206
+ const text = this . editor . document . getText ( ) ;
207
+ if ( text === "" ) {
208
+ this . log ( `EXTENSION: Editor's code is empty, not saving` ) ;
209
+ return ;
210
+ }
211
+ await vscode . workspace . fs . writeFile (
212
+ vscode . Uri . file ( this . editor . document . fileName ) ,
213
+ new TextEncoder ( ) . encode ( text ) ,
214
+ ) ;
215
+ this . log ( `EXTENSION: Editor's code saved successfully` ) ;
216
+ //?: Send the code to the frontend - if needed
217
+ // const message = Messages.Text(
218
+ // this.workspaceLocation,
219
+ // text,
220
+ // );
221
+ // sendToFrontendWrapped(message);
222
+ }
223
+
224
+ async reset ( prepend : string , initialCode : string ) {
201
225
this . log ( `EXTENSION: Editor's reset called` ) ;
202
226
this . replace (
203
227
prepend !== ""
@@ -210,5 +234,7 @@ export class Editor {
210
234
: initialCode ,
211
235
"reset" ,
212
236
) ;
237
+ await this . save ( ) ;
238
+ this . log ( `EXTENSION: Editor's code reset successfully` ) ;
213
239
}
214
240
}
You can’t perform that action at this time.
0 commit comments