@@ -315,31 +315,12 @@ export class Workspace {
315
315
}
316
316
317
317
update_file ( file : File ) {
318
- if ( file . name === this . #current. name ) {
319
- this . #current = file ;
320
- }
321
-
322
- this . #files = this . #files. map ( ( old ) => {
323
- if ( old . name === file . name ) {
324
- return file ;
325
- }
326
- return old ;
327
- } ) ;
328
-
329
- this . modified [ file . name ] = true ;
330
-
331
- if ( BROWSER && is_svelte_file ( file ) ) {
332
- compile_file ( file , this . #svelte_version, this . compiler_options ) . then ( ( compiled ) => {
333
- this . compiled [ file . name ] = compiled ;
334
- } ) ;
335
- }
318
+ this . #update_file( file ) ;
336
319
337
320
const state = this . states . get ( file . name ) ;
338
321
if ( state ) {
339
322
this . #update_state( file , state ) ;
340
323
}
341
-
342
- this . #onupdate( file ) ;
343
324
}
344
325
345
326
#create_directories( item : Item ) {
@@ -374,7 +355,7 @@ export class Workspace {
374
355
if ( update . docChanged ) {
375
356
const state = this . #view! . state ! ;
376
357
377
- this . update_file ( {
358
+ this . # update_file( {
378
359
...this . #current,
379
360
contents : state . doc . toString ( )
380
361
} ) ;
@@ -461,6 +442,29 @@ export class Workspace {
461
442
this . #view?. setState ( this . #get_state( this . #current) ) ;
462
443
}
463
444
445
+ #update_file( file : File ) {
446
+ if ( file . name === this . #current. name ) {
447
+ this . #current = file ;
448
+ }
449
+
450
+ this . #files = this . #files. map ( ( old ) => {
451
+ if ( old . name === file . name ) {
452
+ return file ;
453
+ }
454
+ return old ;
455
+ } ) ;
456
+
457
+ this . modified [ file . name ] = true ;
458
+
459
+ if ( BROWSER && is_svelte_file ( file ) ) {
460
+ compile_file ( file , this . #svelte_version, this . compiler_options ) . then ( ( compiled ) => {
461
+ this . compiled [ file . name ] = compiled ;
462
+ } ) ;
463
+ }
464
+
465
+ this . #onupdate( file ) ;
466
+ }
467
+
464
468
#update_state( file : File , state : EditorState ) {
465
469
const existing = state . doc . toString ( ) ;
466
470
0 commit comments