-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(read_file): VSCode decoding for native tool reads #10518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Review completed. I left 1 inline suggestion to keep native VSCode-decoded reads consistent with the existing out-of-range <line_range> behavior.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| const rawRangeText = | ||
| useNative && maybeText !== undefined | ||
| ? sliceTextLines(maybeText, range.start - 1, range.end - 1) | ||
| : await readLines(fullPath, range.end - 1, range.start - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When native reads use VSCode-decoded text, out-of-range <line_range> values no longer error (for example range.start beyond the file length). readLines() rejects in that case, but sliceTextLines() returns an empty string and addLineNumbers() can emit a misleading blank line like 1000 | .
| const rawRangeText = | |
| useNative && maybeText !== undefined | |
| ? sliceTextLines(maybeText, range.start - 1, range.end - 1) | |
| : await readLines(fullPath, range.end - 1, range.start - 1) | |
| if (useNative && maybeText !== undefined && range.start > totalLines) { | |
| throw new RangeError("Line with index ${range.start - 1} does not exist in \"${fullPath}\". Note that line indexing is zero-based") | |
| } | |
| const rawRangeText = | |
| useNative && maybeText !== undefined | |
| ? sliceTextLines(maybeText, range.start - 1, range.end - 1) | |
| : await readLines(fullPath, range.end - 1, range.start - 1) |
Fix it with Roo Code or mention @roomote and request a fix.
Fixes non-UTF8 file decoding for native tool-calling reads by preferring VSCode’s document decoding (and falling back to the existing byte-based readers).
Closes #3555
·········································································
Test Files 2 passed (2)
Tests 73 passed (73)
Start at 08:28:19
Duration 759ms (transform 262ms, setup 82ms, collect 458ms, tests 189ms, environment 0ms, prepare 62ms)
Important
Enhance
ReadFileToolto use VSCode's document decoding for non-UTF8 files and addreadTextWithTokenBudget()utility.ReadFileToolinReadFileTool.tsnow uses VSCode's document decoding for non-UTF8 files, falling back to byte-based readers if unavailable.tryReadTextViaVscode()andsliceTextLines()functions for handling text reading and slicing.readTextWithTokenBudget()inread-text-with-budget.tsfor reading text with a token budget, mirroringreadFileWithTokenBudget().readFileTool.spec.tsto mock VSCode and test new VSCode decoding path.readTextWithTokenBudget()behavior.This description was created by
for a1aae5d. You can customize this summary. It will automatically update as commits are pushed.