@@ -641,23 +641,6 @@ export class TutorialRunner {
641
641
* cleanup the allocated buffers.
642
642
*/
643
643
const scheduleReadFor = ( filePath : string , encoding : 'utf-8' | null ) => {
644
- const segments = filePath . split ( '/' ) ;
645
- segments . forEach ( ( _ , index ) => {
646
- if ( index == segments . length - 1 ) {
647
- return ;
648
- }
649
-
650
- const folderPath = segments . slice ( 0 , index + 1 ) . join ( '/' ) ;
651
-
652
- if ( ! this . _editorStore . documents . get ( ) [ folderPath ] ) {
653
- this . _editorStore . addFileOrFolder ( { path : folderPath , type : 'folder' } ) ;
654
- }
655
- } ) ;
656
-
657
- if ( ! this . _editorStore . documents . get ( ) [ filePath ] ) {
658
- this . _editorStore . addFileOrFolder ( { path : filePath , type : 'file' } ) ;
659
- }
660
-
661
644
filesToRead . set ( filePath , encoding ) ;
662
645
663
646
clearTimeout ( timeoutId ) ;
@@ -679,6 +662,8 @@ export class TutorialRunner {
679
662
return ;
680
663
}
681
664
665
+ console . log ( eventType , filename ) ;
666
+
682
667
if ( eventType === 'change' ) {
683
668
/**
684
669
* Update file
@@ -699,6 +684,23 @@ export class TutorialRunner {
699
684
this . _editorStore . deleteFile ( filePath ) ;
700
685
} else {
701
686
// add file
687
+ const segments = filePath . split ( '/' ) ;
688
+ segments . forEach ( ( _ , index ) => {
689
+ if ( index == segments . length - 1 ) {
690
+ return ;
691
+ }
692
+
693
+ const folderPath = segments . slice ( 0 , index + 1 ) . join ( '/' ) ;
694
+
695
+ if ( ! this . _editorStore . documents . get ( ) [ folderPath ] ) {
696
+ this . _editorStore . addFileOrFolder ( { path : folderPath , type : 'folder' } ) ;
697
+ }
698
+ } ) ;
699
+
700
+ if ( ! this . _editorStore . documents . get ( ) [ filePath ] ) {
701
+ this . _editorStore . addFileOrFolder ( { path : filePath , type : 'file' } ) ;
702
+ }
703
+
702
704
this . _updateCurrentFiles ( { [ filePath ] : '' } ) ;
703
705
scheduleReadFor ( filePath , 'utf-8' ) ;
704
706
}
0 commit comments