diff

package
v1.3.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package diff renders a *fs.FileDiff (the structured metadata write_file / edit_file attach to tools.Result) as a multi-line git-style string with a gutter / content split.

Layout per row:

|<oldNum>|<newNum>|<sign>| <text>
└─ gutter (muted) ──────┘└─ content ─┘

The gutter holds the two line-number columns and the +/-/space sign; the content column holds the actual file text with syntax highlighting applied via chroma (keyed by file extension). Splitting them matters for terminal copy-paste — selecting just the content column is the right ergonomic, line numbers shouldn't paste into the clipboard as if they were code.

Width handling: gutter width adapts to the largest line number in the diff so a 9-line file doesn't reserve four columns of empty space. Content rows still take an optional `width` arg for the background-fill behavior on add/remove rows (M2 visual contract).

Lives in components/ because it's reused by both the transcript tool-result block (M3) and the permission overlay's diff preview (M10). Theme-free callers can pass theme.Default().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(d *fs.FileDiff, th *theme.Theme, width int) string

Render returns a multi-line styled diff. width is the column count each + / - row's CONTENT column is padded to so its background tint reads as a solid block across the transcript column. width <= 0 disables the fill (used in tests). The gutter prefix is added on top of width — callers sizing the transcript column should pass the full available width and trust Render to subtract the gutter.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL