From 5cb68652f9eddd16d3571a0513bdd18f224f8a2d Mon Sep 17 00:00:00 2001 From: XiaoFeng <117837368+Fzhiyu1@users.noreply.github.com> Date: Fri, 26 Dec 2025 15:40:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20file=5Flist=20=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E5=90=8C=E6=97=B6=E8=BF=94=E5=9B=9E=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=92=8C=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/readFiles.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/readFiles.ts b/src/utils/readFiles.ts index 133cb16..e92f8d7 100644 --- a/src/utils/readFiles.ts +++ b/src/utils/readFiles.ts @@ -94,6 +94,13 @@ export async function readDirectory( const results = []; for (const [fileName, fileType] of entries) { + // 处理目录 + if (fileType === vscode.FileType.Directory) { + results.push({ path: fileName + '/', content: '[目录]', isDirectory: true }); + continue; + } + + // 处理文件 if (fileType === vscode.FileType.File) { // 如果指定了扩展名过滤 if (extensions && extensions.length > 0) { @@ -108,7 +115,7 @@ export async function readDirectory( const fileUri = vscode.Uri.file(filePath); const contentBytes = await vscode.workspace.fs.readFile(fileUri); const content = Buffer.from(contentBytes).toString("utf-8"); - results.push({ path: fileName, content }); + results.push({ path: fileName, content, isDirectory: false }); } catch (error) { // 跳过无法读取的文件 continue;