Skip to content

Commit 80c8613

Browse files
committed
minor fix
1 parent d12bb5f commit 80c8613

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/core/src/shared/utilities/workspaceUtils.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ export function formatListing(name: string, fileType: vscode.FileType, fullPath:
693693
* You can either pass a custom callback or rely on the default `formatListing`.
694694
*
695695
* @param dirUri The folder to begin traversing
696-
* @param maxDepth Maximum depth to descend (0 => just this folder, if it's missing -> recursively)
696+
* @param maxDepth Maximum depth to descend (0 => just this folder, if it's missing => recursively)
697697
* @param customFormatCallback Optional. If given, it will override the default line-formatting
698698
*/
699699
export async function readDirectoryRecursively(
@@ -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 && 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

Comments
 (0)