@@ -96,12 +96,13 @@ export class WorkspaceProvider
9696 context : vscode . ExtensionContext
9797 } ) {
9898 this . _context = params . context
99- this . _workspace_roots = params . workspace_folders . map (
100- ( folder ) => folder . uri . fsPath
101- )
102- this . _workspace_names = params . workspace_folders . map (
103- ( folder ) => folder . name
99+ const valid_folders = params . workspace_folders . filter ( ( folder ) =>
100+ fs . existsSync ( folder . uri . fsPath )
104101 )
102+
103+ this . _workspace_roots = valid_folders . map ( ( folder ) => folder . uri . fsPath )
104+ this . _workspace_names = valid_folders . map ( ( folder ) => folder . name )
105+
105106 this . onDidChangeCheckedFiles ( ( ) => this . _save_checked_files_state ( ) )
106107 this . _token_calculator = new TokenCalculator ( this , this . _context )
107108 this . _load_ignore_patterns ( )
@@ -675,6 +676,9 @@ export class WorkspaceProvider
675676
676677 if ( this . _workspace_roots . length == 1 ) {
677678 const single_root = this . _workspace_roots [ 0 ]
679+ if ( ! fs . existsSync ( single_root ) ) {
680+ return [ ]
681+ }
678682 const items =
679683 await this . _token_calculator . with_token_counting_notification ( ( ) =>
680684 this . _get_files_and_directories ( single_root )
@@ -712,6 +716,9 @@ export class WorkspaceProvider
712716 }
713717
714718 if ( this . _workspace_roots . length == 1 ) {
719+ if ( ! fs . existsSync ( this . _workspace_roots [ 0 ] ) ) {
720+ return [ ]
721+ }
715722 return this . _get_files_and_directories ( this . _workspace_roots [ 0 ] , true )
716723 } else {
717724 return this . _get_workspace_folder_items ( true )
@@ -725,6 +732,10 @@ export class WorkspaceProvider
725732 for ( let i = 0 ; i < this . _workspace_roots . length ; i ++ ) {
726733 const root = this . _workspace_roots [ i ]
727734
735+ if ( ! fs . existsSync ( root ) ) {
736+ continue
737+ }
738+
728739 if ( context_view ) {
729740 const state = this . _checked_items . get ( root )
730741 const is_partially_checked = this . _partially_checked_dirs . has ( root )
@@ -1620,8 +1631,12 @@ export class WorkspaceProvider
16201631 ) : Promise < void > {
16211632 const checked_paths = this . get_all_checked_paths ( )
16221633
1623- this . _workspace_roots = workspace_folders . map ( ( folder ) => folder . uri . fsPath )
1624- this . _workspace_names = workspace_folders . map ( ( folder ) => folder . name )
1634+ const valid_folders = workspace_folders . filter ( ( folder ) =>
1635+ fs . existsSync ( folder . uri . fsPath )
1636+ )
1637+
1638+ this . _workspace_roots = valid_folders . map ( ( folder ) => folder . uri . fsPath )
1639+ this . _workspace_names = valid_folders . map ( ( folder ) => folder . name )
16251640
16261641 // Clear caches that depend on workspace structure
16271642 this . _file_workspace_map . clear ( )
0 commit comments