@@ -702,8 +702,7 @@ export async function readDirectoryRecursively(
702702 customFormatCallback ?: ( name : string , fileType : vscode . FileType , fullPath : string ) => string
703703) : Promise < string [ ] > {
704704 const logger = getLogger ( )
705- maxDepth = maxDepth ?? - 1
706- const depthDescription = maxDepth < 0 ? 'unlimited' : maxDepth
705+ const depthDescription = maxDepth === undefined ? 'unlimited' : maxDepth
707706 logger . info ( `Reading directory: ${ dirUri . fsPath } to max depth: ${ depthDescription } ` )
708707
709708 const queue : Array < { uri : vscode . Uri ; depth : number } > = [ { uri : dirUri , depth : 0 } ]
@@ -713,7 +712,7 @@ export async function readDirectoryRecursively(
713712
714713 while ( queue . length > 0 ) {
715714 const { uri, depth } = queue . shift ( ) !
716- if ( maxDepth >= 0 && depth > maxDepth ) {
715+ if ( maxDepth !== undefined && maxDepth >= 0 && depth > maxDepth ) {
717716 logger . info ( `Skipping directory: ${ uri . fsPath } (depth ${ depth } > max ${ maxDepth } )` )
718717 continue
719718 }
@@ -731,7 +730,7 @@ export async function readDirectoryRecursively(
731730 const childUri = vscode . Uri . joinPath ( uri , name )
732731 results . push ( formatter ( name , fileType , childUri . fsPath ) )
733732
734- if ( fileType === vscode . FileType . Directory && ( maxDepth < 0 || depth < maxDepth ) ) {
733+ if ( fileType === vscode . FileType . Directory && ( maxDepth === undefined || depth < maxDepth ) ) {
735734 queue . push ( { uri : childUri , depth : depth + 1 } )
736735 }
737736 }
0 commit comments