# Prefix read_file tool output with line numbers \(\#56779\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/cfd0461b5a93898fd814659786bc3ff9b4b18e45)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: cfd0461b5a93898fd814659786bc3ff9b4b18e45

Requested commit: cfd0461b5a93898fd814659786bc3ff9b4b18e45

Commit: cfd0461b5a93898fd814659786bc3ff9b4b18e45

Tree: bb58a0c541a75c6528745f6d1c0a769f7822ccf9

Author: MartinYe1234

Committer: GitHub

## Message

```
Prefix read_file tool output with line numbers (#56779)

Format `read_file` tool output in `cat -n` style: each line is prefixed
with its line number right-aligned in a 6-character field, followed by a
single tab, followed by the line's original content (newlines preserved,
including CRLF). Numbering reflects the actual file lines, so a ranged
read starting at line 42 emits `42` for its first line, not `1`.

For large files, content returned by `get_buffer_content_or_outline` is
**not** prefixed:

- The symbol outline path already conveys structure via its `[L100-150]`
annotations.
- The truncated first-1KB fallback (used when a file exceeds
`AUTO_OUTLINE_SIZE` and has no parseable outline) is wrapped in a
synthetic `# First 1KB of …` header, so its lines don't correspond to
real file line numbers.

Both cases are reported via `BufferContent::is_synthetic` (renamed from
`is_outline`).

Also updates the `edit_file` tool's input doc to describe the prefix
format and tell the model to strip it before constructing `old_text` /
`new_text`, preserving the original indentation that appears after the
tab.

Updates how we render `read_file` tool call outputs in the UI
(screenshots included in comments below).
Also fixes an existing bug where `read_file` tool call outputs would not
re-render their content code block when an older thread was restored
(the tool's `replay` hook was missing).

Closes AI-226

Release Notes:

- Improved how `read_file` tool output renders in the agent panel, with
a line-number gutter, and fixed it not re-rendering on restored threads

---------

Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
```

## Parents

- [949d9931462ffa75b1873522b0d7976f9518e2bf](https://git.cafe/gitcafe/zed/commit/949d9931462ffa75b1873522b0d7976f9518e2bf?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/cfd0461b5a93898fd814659786bc3ff9b4b18e45?format=markdown)
