diff --git a/diff/diff.go b/diff/diff.go index 6b317d8..0633c18 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -46,6 +46,7 @@ type twoints struct { } func Diff(o, n []string) []Instruction { + if len(o) == 0 && len(n) == 0 { return []Instruction{} } @@ -91,9 +92,7 @@ func Diff(o, n []string) []Instruction { } ret := Diff(o[:omax], n[:nmax]) - if maxl != nmax { - ret = append(ret, Instruction{OP_UNCHANGED, n[nmax : maxl-nmax]}) - } + ret = append(ret, Instruction{OP_UNCHANGED, n[nmax : nmax+maxl]}) ret = append(ret, Diff(o[omax+maxl:], n[nmax+maxl:])...) return ret