@@ -1039,14 +1039,18 @@ export class WorkspaceProvider
10391039 } )
10401040
10411041 dir_entries . sort ( ( a , b ) => {
1042- const a_is_dir = a . isDirectory ( ) || a . isSymbolicLink ( )
1043- const b_is_dir = b . isDirectory ( ) || b . isSymbolicLink ( )
1042+ const a_is_dir = a . isDirectory ( )
1043+ const b_is_dir = b . isDirectory ( )
10441044 if ( a_is_dir && ! b_is_dir ) return - 1
10451045 if ( ! a_is_dir && b_is_dir ) return 1
10461046 return natural_sort ( a . name , b . name )
10471047 } )
10481048
10491049 for ( const entry of dir_entries ) {
1050+ if ( entry . isSymbolicLink ( ) ) {
1051+ continue
1052+ }
1053+
10501054 const full_path = path . join ( dir_path , entry . name )
10511055
10521056 // Exclude nested workspace folders from appearing in parent workspace trees
@@ -1062,20 +1066,9 @@ export class WorkspaceProvider
10621066 const is_partially_checked =
10631067 this . _partially_checked_dirs . has ( full_path )
10641068
1065- let is_directory_for_check = entry . isDirectory ( )
1066- if ( entry . isSymbolicLink ( ) ) {
1067- try {
1068- is_directory_for_check = (
1069- await fs . promises . stat ( full_path )
1070- ) . isDirectory ( )
1071- } catch {
1072- // broken symlink, will be skipped later
1073- }
1074- }
1075-
10761069 if (
10771070 state != vscode . TreeItemCheckboxState . Checked &&
1078- ! ( is_directory_for_check && is_partially_checked )
1071+ ! ( entry . isDirectory ( ) && is_partially_checked )
10791072 ) {
10801073 continue
10811074 }
@@ -1094,24 +1087,7 @@ export class WorkspaceProvider
10941087 }
10951088
10961089 const uri = vscode . Uri . file ( full_path )
1097- let is_directory = entry . isDirectory ( )
1098- const is_symbolic_link = entry . isSymbolicLink ( )
1099- let is_broken_link = false
1100-
1101- if ( is_symbolic_link ) {
1102- try {
1103- const stats = await fs . promises . stat ( full_path )
1104- is_directory = stats . isDirectory ( )
1105- } catch ( err ) {
1106- // The symlink is broken
1107- is_broken_link = true
1108- }
1109- }
1110-
1111- if ( is_broken_link ) {
1112- continue
1113- }
1114-
1090+ const is_directory = entry . isDirectory ( )
11151091 const key = full_path
11161092
11171093 let checkbox_state = this . _checked_items . get ( key )
@@ -1151,7 +1127,7 @@ export class WorkspaceProvider
11511127 : vscode . TreeItemCollapsibleState . None ,
11521128 is_directory ,
11531129 this . _is_no_context_mode ? undefined : checkbox_state ,
1154- is_symbolic_link ,
1130+ false ,
11551131 false ,
11561132 tokens . total ,
11571133 tokens . shrink ,
@@ -1248,6 +1224,10 @@ export class WorkspaceProvider
12481224 let has_non_ignored_child = false
12491225
12501226 for ( const entry of dir_entries ) {
1227+ if ( entry . isSymbolicLink ( ) ) {
1228+ continue
1229+ }
1230+
12511231 const sibling_path = path . join ( dir_path , entry . name )
12521232
12531233 const file_workspace_root =
@@ -1357,6 +1337,10 @@ export class WorkspaceProvider
13571337 } )
13581338
13591339 for ( const entry of dir_entries ) {
1340+ if ( entry . isSymbolicLink ( ) ) {
1341+ continue
1342+ }
1343+
13601344 const full_path = path . join ( dir_path , entry . name )
13611345
13621346 const file_workspace_root = this . get_workspace_root_for_file ( full_path )
@@ -1387,21 +1371,7 @@ export class WorkspaceProvider
13871371 this . _checked_timestamps . delete ( full_path )
13881372 }
13891373
1390- let is_directory = entry . isDirectory ( )
1391- const is_symbolic_link = entry . isSymbolicLink ( )
1392- let is_broken_link = false
1393-
1394- if ( is_symbolic_link ) {
1395- try {
1396- const stats = await fs . promises . stat ( full_path )
1397- is_directory = stats . isDirectory ( )
1398- } catch {
1399- // The symlink is broken
1400- is_broken_link = true
1401- }
1402- }
1403-
1404- if ( is_directory && ! is_broken_link ) {
1374+ if ( entry . isDirectory ( ) ) {
14051375 await this . _update_directory_check_state ( full_path , state , false )
14061376 }
14071377 }
@@ -1426,8 +1396,7 @@ export class WorkspaceProvider
14261396 ( [ file_path , state ] ) =>
14271397 state == vscode . TreeItemCheckboxState . Checked &&
14281398 fs . existsSync ( file_path ) &&
1429- ( fs . lstatSync ( file_path ) . isFile ( ) ||
1430- fs . lstatSync ( file_path ) . isSymbolicLink ( ) ) &&
1399+ fs . lstatSync ( file_path ) . isFile ( ) &&
14311400 ( ( ) => {
14321401 const workspace_root = this . get_workspace_root_for_file ( file_path )
14331402 return workspace_root
@@ -1461,30 +1430,39 @@ export class WorkspaceProvider
14611430 for ( const file_path of file_paths ) {
14621431 if ( ! fs . existsSync ( file_path ) ) continue
14631432
1464- const workspace_root = this . get_workspace_root_for_file ( file_path )
1465- if ( ! workspace_root ) continue
1433+ try {
1434+ const stats = fs . lstatSync ( file_path )
1435+ if ( stats . isSymbolicLink ( ) ) continue
14661436
1467- const stats = fs . lstatSync ( file_path )
1468- const is_directory = stats . isDirectory ( )
1437+ const workspace_root = this . get_workspace_root_for_file ( file_path )
1438+ if ( ! workspace_root ) continue
14691439
1470- const relative_path = path . relative ( workspace_root , file_path )
1471- if (
1472- this . is_excluded ( is_directory ? relative_path + '/' : relative_path )
1473- ) {
1474- continue
1475- }
1440+ const is_directory = stats . isDirectory ( )
14761441
1477- if ( is_directory ) {
1478- this . _checked_items . set ( file_path , vscode . TreeItemCheckboxState . Checked )
1479- await this . _update_directory_check_state (
1480- file_path ,
1481- vscode . TreeItemCheckboxState . Checked ,
1482- false
1483- )
1484- } else {
1485- if ( ! this . is_ignored_by_patterns ( file_path ) ) {
1486- all_files_to_check . push ( file_path )
1442+ const relative_path = path . relative ( workspace_root , file_path )
1443+ if (
1444+ this . is_excluded ( is_directory ? relative_path + '/' : relative_path )
1445+ ) {
1446+ continue
1447+ }
1448+
1449+ if ( is_directory ) {
1450+ this . _checked_items . set (
1451+ file_path ,
1452+ vscode . TreeItemCheckboxState . Checked
1453+ )
1454+ await this . _update_directory_check_state (
1455+ file_path ,
1456+ vscode . TreeItemCheckboxState . Checked ,
1457+ false
1458+ )
1459+ } else {
1460+ if ( ! this . is_ignored_by_patterns ( file_path ) ) {
1461+ all_files_to_check . push ( file_path )
1462+ }
14871463 }
1464+ } catch ( e ) {
1465+ // Ignore file access errors
14881466 }
14891467 }
14901468
@@ -1526,21 +1504,13 @@ export class WorkspaceProvider
15261504 } )
15271505
15281506 for ( const entry of entries ) {
1507+ if ( entry . isSymbolicLink ( ) ) continue
1508+
15291509 if ( entry . name == '.git' || entry . name == 'node_modules' ) continue
15301510
15311511 const full_path = path . join ( dir_path , entry . name )
15321512
1533- let is_directory = entry . isDirectory ( )
1534- if ( entry . isSymbolicLink ( ) ) {
1535- try {
1536- const stats = await fs . promises . stat ( full_path )
1537- is_directory = stats . isDirectory ( )
1538- } catch {
1539- continue
1540- }
1541- }
1542-
1543- if ( is_directory ) {
1513+ if ( entry . isDirectory ( ) ) {
15441514 await walk ( full_path )
15451515 } else if (
15461516 [ '.gitignore' , '.cursorignore' , '.codeiumignore' ] . includes (
@@ -1736,6 +1706,10 @@ export class WorkspaceProvider
17361706 } )
17371707
17381708 for ( const entry of entries ) {
1709+ if ( entry . isSymbolicLink ( ) ) {
1710+ continue
1711+ }
1712+
17391713 const full_path = path . join ( dir_path , entry . name )
17401714
17411715 const file_workspace_root =
@@ -1754,24 +1728,7 @@ export class WorkspaceProvider
17541728 continue
17551729 }
17561730
1757- let is_directory = entry . isDirectory ( )
1758- const is_symbolic_link = entry . isSymbolicLink ( )
1759- let is_broken_link = false
1760-
1761- if ( is_symbolic_link ) {
1762- try {
1763- const stats = await fs . promises . stat ( full_path )
1764- is_directory = stats . isDirectory ( )
1765- } catch {
1766- is_broken_link = true
1767- }
1768- }
1769-
1770- if ( is_broken_link ) {
1771- continue
1772- }
1773-
1774- if ( is_directory ) {
1731+ if ( entry . isDirectory ( ) ) {
17751732 await walk ( full_path )
17761733 } else if ( ! this . is_ignored_by_patterns ( full_path ) ) {
17771734 files . push ( full_path )
0 commit comments