Skip to content

Commit f5628e5

Browse files
authored
Support mentioning binary files (#1880)
1 parent 8663e52 commit f5628e5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.changeset/wise-icons-sort.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Support mentioning binary files

src/core/mentions/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@ async function getFileOrFolderContent(mentionPath: string, cwd: string): Promise
152152
const stats = await fs.stat(absPath)
153153

154154
if (stats.isFile()) {
155-
const isBinary = await isBinaryFile(absPath).catch(() => false)
156-
if (isBinary) {
157-
return "(Binary file, unable to display content)"
155+
try {
156+
const content = await extractTextFromFile(absPath)
157+
return content
158+
} catch (error) {
159+
return `(Failed to read contents of ${mentionPath}): ${error.message}`
158160
}
159-
const content = await extractTextFromFile(absPath)
160-
return content
161161
} else if (stats.isDirectory()) {
162162
const entries = await fs.readdir(absPath, { withFileTypes: true })
163163
let folderContent = ""

0 commit comments

Comments
 (0)