diff --git a/diff/diff.go b/diff/diff.go index 9fcb02b..6b317d8 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -49,6 +49,12 @@ func Diff(o, n []string) []Instruction { if len(o) == 0 && len(n) == 0 { return []Instruction{} } + if len(o) == 0 { + return []Instruction{{OP_INSERTED, n}} + } + if len(n) == 0 { + return []Instruction{{OP_REMOVED, o}} + } maxl := 0 omax := 0 @@ -79,8 +85,8 @@ func Diff(o, n []string) []Instruction { if maxl == 0 { return []Instruction{ - Instruction{OP_REMOVED, o}, - Instruction{OP_INSERTED, n}, + {OP_REMOVED, o}, + {OP_INSERTED, n}, } }