Documentation
¶
Overview ¶
Package diff computes unified-style diffs for proposed file writes. The FileDiff type is consumed by both the TUI and the future web server.
Index ¶
Constants ¶
View Source
const MaxDiffLines = 500
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiffLine ¶
type DiffLine struct {
Kind LineKind `json:"kind"`
Content string `json:"content"`
Spans []WordSpan `json:"spans,omitempty"` // populated for matched Remove+Add pairs
}
DiffLine is one line of a diff output.
type FileDiff ¶
type FileDiff struct {
Path string
IsNew bool
IsDeleted bool
Adds int
Removes int
Lines []DiffLine // capped at MaxDiffLines body lines
Truncated int // number of body lines omitted due to cap
}
FileDiff is the result of diffing one proposed write against the on-disk file.
func Compute ¶
Compute diffs newContent against the file at path. If the file does not exist it is treated as empty (new file).
func ComputeDeleted ¶
ComputeDeleted produces a diff for a file being deleted. It reads the file from disk and produces a diff where all lines are removals. If the file does not exist or cannot be read, it returns a minimal FileDiff.
Click to show internal directories.
Click to hide internal directories.