Don’t apply text diff if an error occurs

This commit is contained in:
Tobie Morgan Hitchcock 2018-12-28 10:53:28 +01:00
parent 9819b64dc6
commit c8d70c780c

View file

@ -239,9 +239,10 @@ func (o *operations) patch(old map[string]interface{}) (now map[string]interface
case "change":
if txt, ok := obj.Get(path...).Data().(string); ok {
dmp := diffmatchpatch.New()
dif, _ := dmp.DiffFromDelta(txt, v.value.(string))
str := dmp.DiffText2(dif)
obj.Set(str, path...)
if dif, err := dmp.DiffFromDelta(txt, v.value.(string)); err == nil {
str := dmp.DiffText2(dif)
obj.Set(str, path...)
}
}
}