PatchDeepCopy returns an array that is identical to a given an array of patches.
(patches []Patch)
| 210 | |
| 211 | // PatchDeepCopy returns an array that is identical to a given an array of patches. |
| 212 | func (dmp *DiffMatchPatch) PatchDeepCopy(patches []Patch) []Patch { |
| 213 | patchesCopy := []Patch{} |
| 214 | for _, aPatch := range patches { |
| 215 | patchCopy := Patch{} |
| 216 | for _, aDiff := range aPatch.diffs { |
| 217 | patchCopy.diffs = append(patchCopy.diffs, Diff{ |
| 218 | aDiff.Type, |
| 219 | aDiff.Text, |
| 220 | }) |
| 221 | } |
| 222 | patchCopy.Start1 = aPatch.Start1 |
| 223 | patchCopy.Start2 = aPatch.Start2 |
| 224 | patchCopy.Length1 = aPatch.Length1 |
| 225 | patchCopy.Length2 = aPatch.Length2 |
| 226 | patchesCopy = append(patchesCopy, patchCopy) |
| 227 | } |
| 228 | return patchesCopy |
| 229 | } |
| 230 | |
| 231 | // PatchApply merges a set of patches onto the text. Returns a patched text, as well as an array of true/false values indicating which patches were applied. |
| 232 | func (dmp *DiffMatchPatch) PatchApply(patches []Patch, text string) (string, []bool) { |