Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MapOldLineToNew ¶
MapOldLineToNew builds a mapping from old line numbers to new line numbers using the diff entries. For unchanged lines it maps directly. For removed lines it maps to the nearest subsequent new line in the new document. Returns a map[int]int where key=old line, value=new line.
func SplitLines ¶
SplitLines splits content into lines, returning an empty slice for empty input.
Types ¶
type DiffEntry ¶
type DiffEntry struct {
Type string `json:"type"` // "unchanged", "added", or "removed"
OldLine int `json:"old_line,omitempty"` // 1-based line number in old content (0 if added)
NewLine int `json:"new_line,omitempty"` // 1-based line number in new content (0 if removed)
Text string `json:"text"`
}
DiffEntry represents a single line in the diff output.
func ComputeLineDiff ¶
ComputeLineDiff computes a line-level diff between oldContent and newContent using Hirschberg's algorithm (divide-and-conquer LCS in O(n) space). Each line is classified as "unchanged", "added", or "removed".
type DiffHunk ¶
type DiffHunk struct {
OldStart int
OldCount int
NewStart int
NewCount int
Header string // the @@ line text
Lines []DiffLine
}
DiffHunk represents a single hunk in a unified diff.
func DiffEntriesToHunks ¶
DiffEntriesToHunks converts LCS diff entries into DiffHunk format (same as git diff), so the frontend can use one unified renderer. Groups changes with 3 lines of context.