@@ -641,23 +641,6 @@ export class TutorialRunner {
641641 * cleanup the allocated buffers.
642642 */
643643 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-
661644 filesToRead . set ( filePath , encoding ) ;
662645
663646 clearTimeout ( timeoutId ) ;
@@ -679,6 +662,8 @@ export class TutorialRunner {
679662 return ;
680663 }
681664
665+ console . log ( eventType , filename ) ;
666+
682667 if ( eventType === 'change' ) {
683668 /**
684669 * Update file
@@ -699,6 +684,23 @@ export class TutorialRunner {
699684 this . _editorStore . deleteFile ( filePath ) ;
700685 } else {
701686 // 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+
702704 this . _updateCurrentFiles ( { [ filePath ] : '' } ) ;
703705 scheduleReadFor ( filePath , 'utf-8' ) ;
704706 }
0 commit comments