Support mentioning binary files (#1880)

This commit is contained in:
Matt Rubens 2025-03-21 10:51:44 -04:00 committed by GitHub
parent 8663e52e8d
commit f5628e573f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View file

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

View file

@ -152,12 +152,12 @@ async function getFileOrFolderContent(mentionPath: string, cwd: string): Promise
const stats = await fs.stat(absPath)
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()) {
const entries = await fs.readdir(absPath, { withFileTypes: true })
let folderContent = ""