1.4 KiB
1.4 KiB
module diff
Contents
diff
fn diff[T](a []T, b []T) &DiffContext[T]
diff returns the difference of two arrays.
DiffContext[T]
generate_patch
fn (mut c DiffContext[T]) generate_patch(param DiffGenStrParam) string
generate_patch generate a diff string of two arrays.
DiffChange
struct DiffChange {
pub mut:
a int // position in input a []T
b int // position in input b []T
del int // delete Del elements from input a
ins int // insert Ins elements from input b
}
DiffChange contains one or more deletions or inserts at one position in two arrays.
DiffContext
struct DiffContext[T] {
mut:
a []T
b []T
flags []DiffContextFlag
max int
// forward and reverse d-path endpoint x components
forward []int
reverse []int
pub mut:
changes []DiffChange
}
DiffGenStrParam
struct DiffGenStrParam {
pub mut:
colorful bool
unified int = 3 // how many context lines before/after diff block
block_header bool // output `@@ -3,4 +3,5 @@` or not
}