@@ -365,82 +365,7 @@ export class WorkspaceProvider
365365 this . directory_selected_token_counts . clear ( )
366366 }
367367
368- this . update_file_workspace_mapping ( )
369-
370- await this . refresh ( )
371-
372- let internal_check_state_changed = false
373- // Take a snapshot of the checked items before potential modifications
374- const initial_checked_items_state = new Map ( this . checked_items . entries ( ) )
375-
376- // If a new file is created within a checked directory, it should also be checked (if not excluded).
377- // Iterate over a snapshot of items that were checked BEFORE this method's logic began fully.
378- for ( const [ item_path_key , item_state_val ] of initial_checked_items_state ) {
379- if ( item_state_val === vscode . TreeItemCheckboxState . Checked ) {
380- // We are interested if item_path_key is a directory that could contain created_file_path,
381- // or if created_file_path is null (less specific), we re-evaluate all checked directories.
382- let needs_re_evaluation = false
383- try {
384- if (
385- fs . existsSync ( item_path_key ) &&
386- fs . lstatSync ( item_path_key ) . isDirectory ( )
387- ) {
388- if ( created_file_path ) {
389- // Only process if item_path_key is a parent (or ancestor) of created_file_path
390- if ( created_file_path . startsWith ( item_path_key + path . sep ) ) {
391- needs_re_evaluation = true
392- }
393- } else {
394- needs_re_evaluation = true // No specific file, re-evaluate all checked dirs
395- }
396- }
397- } catch ( e ) {
398- /* item_path_key might not be a dir or might be gone */
399- }
400-
401- if ( needs_re_evaluation ) {
402- const workspace_root = this . get_workspace_root_for_file ( item_path_key )
403- if ( ! workspace_root ) continue
404-
405- const relative_path = path . relative ( workspace_root , item_path_key )
406- const is_excluded = this . is_excluded ( relative_path )
407-
408- // This call directly modifies `this.checked_items` for children of item_path_key.
409- await this . update_directory_check_state (
410- item_path_key ,
411- vscode . TreeItemCheckboxState . Checked ,
412- is_excluded
413- )
414- }
415- }
416- }
417-
418- if ( this . checked_items . size !== initial_checked_items_state . size ) {
419- internal_check_state_changed = true
420- } else {
421- for ( const [ key , value ] of this . checked_items ) {
422- if ( initial_checked_items_state . get ( key ) !== value ) {
423- internal_check_state_changed = true
424- break
425- }
426- }
427- // Also check if any keys were removed from initial_checked_items_state but not present in this.checked_items
428- if ( ! internal_check_state_changed ) {
429- for ( const key of initial_checked_items_state . keys ( ) ) {
430- if ( ! this . checked_items . has ( key ) ) {
431- internal_check_state_changed = true
432- break
433- }
434- }
435- }
436- }
437-
438- if ( internal_check_state_changed ) {
439- this . _on_did_change_checked_files . fire ( )
440- // Refresh again if this provider's UI also needs to reflect the new check states.
441- // This ensures consistency within this provider's view.
442- await this . refresh ( )
443- }
368+ this . on_file_system_changed ( created_file_path )
444369 }
445370
446371 async refresh ( ) : Promise < void > {
0 commit comments