fix(operation): report actual file total_lines instead of content slice line count#2771
Merged
tusharmath merged 3 commits intomainfrom Apr 1, 2026
Merged
fix(operation): report actual file total_lines instead of content slice line count#2771tusharmath merged 3 commits intomainfrom
tusharmath merged 3 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
total_linesattribute in file read output to report the actual total line count of the file rather than the number of lines in the returned content slice.Context
When reading a file with an explicit line range or when truncation is applied, the
total_linesXML attribute was computed ascontent.lines().count()— i.e., the number of lines in the returned content rather than the total number of lines in the full file. This caused the attribute to be misleading: an agent reading lines 2–3 of a 5-line file would seetotal_lines="3"instead oftotal_lines="5", and a truncated read of a 200-line file would reporttotal_lines="1".The
FileInfostruct already carries the correcttotal_linesvalue populated during the read operation, so the fix is straightforward.Changes
content.lines().count()withoutput.info.total_lineswhen emitting thetotal_linesXML attribute inoperation.rsfs_read_with_explicit_range:total_linesnow correctly shows5(full file) instead of3(lines in the range)fs_read_with_truncation_path:total_linesnow correctly shows200(full file) instead of1(lines in the truncated output)Testing
cargo insta test --accept -p forge_appBoth snapshot tests now assert the correct
total_linesvalue that reflects the actual file size.