mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
Don't do partial reads on binary files (#1886)
This commit is contained in:
parent
e075fbfa90
commit
def40180dc
1 changed files with 4 additions and 1 deletions
|
|
@ -82,6 +82,7 @@ import { validateToolUse, isToolAllowedForMode, ToolName } from "./mode-validato
|
|||
import { parseXml } from "../utils/xml"
|
||||
import { readLines } from "../integrations/misc/read-lines"
|
||||
import { getWorkspacePath } from "../utils/path"
|
||||
import { isBinaryFile } from "isbinaryfile"
|
||||
|
||||
type ToolResponse = string | Array<Anthropic.TextBlockParam | Anthropic.ImageBlockParam>
|
||||
type UserContent = Array<Anthropic.Messages.ContentBlockParam>
|
||||
|
|
@ -2324,6 +2325,8 @@ export class Cline extends EventEmitter<ClineEvents> {
|
|||
let isFileTruncated = false
|
||||
let sourceCodeDef = ""
|
||||
|
||||
const isBinary = await isBinaryFile(absolutePath).catch(() => false)
|
||||
|
||||
if (isRangeRead) {
|
||||
if (startLine === undefined) {
|
||||
content = addLineNumbers(await readLines(absolutePath, endLine, startLine))
|
||||
|
|
@ -2333,7 +2336,7 @@ export class Cline extends EventEmitter<ClineEvents> {
|
|||
startLine,
|
||||
)
|
||||
}
|
||||
} else if (totalLines > maxReadFileLine) {
|
||||
} else if (!isBinary && totalLines > maxReadFileLine) {
|
||||
// If file is too large, only read the first maxReadFileLine lines
|
||||
isFileTruncated = true
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue