MCPcopy Create free account
hub / github.com/cogentcore/core / DiffLines

Function DiffLines

texteditor/text/diff.go:83–86  ·  view source on GitHub ↗

DiffLines computes the diff between two string arrays (one string per line), reporting a sequence of operations that would convert buffer a into buffer b. Each operation is either an 'r' (replace), 'd' (delete), 'i' (insert) or 'e' (equal). Everything is line-based (0, offset).

(astr, bstr []string)

Source from the content-addressed store, hash-verified

81// Each operation is either an 'r' (replace), 'd' (delete), 'i' (insert)
82// or 'e' (equal). Everything is line-based (0, offset).
83func DiffLines(astr, bstr []string) Diffs {
84 m := difflib.NewMatcherWithJunk(astr, bstr, false, nil) // no junk
85 return m.GetOpCodes()
86}
87
88// DiffLinesUnified computes the diff between two string arrays (one string per line),
89// returning a unified diff with given amount of context (default of 3 will be

Callers 5

SaveStateMethod · 0.92
tagWordDiffsMethod · 0.92
SetStringLinesMethod · 0.85
TestDiffFunction · 0.85
diffBuffersMethod · 0.85

Calls 2

NewMatcherWithJunkFunction · 0.92
GetOpCodesMethod · 0.45

Tested by 1

TestDiffFunction · 0.68