Просмотр исходного кода

Support mentioning binary files (#1880)

Matt Rubens 9 месяцев назад
Родитель
Сommit
f5628e573f
2 измененных файлов с 10 добавлено и 5 удалено
  1. 5 0
      .changeset/wise-icons-sort.md
  2. 5 5
      src/core/mentions/index.ts

+ 5 - 0
.changeset/wise-icons-sort.md

@@ -0,0 +1,5 @@
+---
+"roo-cline": patch
+---
+
+Support mentioning binary files

+ 5 - 5
src/core/mentions/index.ts

@@ -152,12 +152,12 @@ async function getFileOrFolderContent(mentionPath: string, cwd: string): Promise
 		const stats = await fs.stat(absPath)
 		const stats = await fs.stat(absPath)
 
 
 		if (stats.isFile()) {
 		if (stats.isFile()) {
-			const isBinary = await isBinaryFile(absPath).catch(() => false)
-			if (isBinary) {
-				return "(Binary file, unable to display content)"
+			try {
+				const content = await extractTextFromFile(absPath)
+				return content
+			} catch (error) {
+				return `(Failed to read contents of ${mentionPath}): ${error.message}`
 			}
 			}
-			const content = await extractTextFromFile(absPath)
-			return content
 		} else if (stats.isDirectory()) {
 		} else if (stats.isDirectory()) {
 			const entries = await fs.readdir(absPath, { withFileTypes: true })
 			const entries = await fs.readdir(absPath, { withFileTypes: true })
 			let folderContent = ""
 			let folderContent = ""