MCPcopy Create free account
hub / github.com/sergi/go-diff / PatchDeepCopy

Method PatchDeepCopy

diffmatchpatch/patch.go:212–229  ·  view source on GitHub ↗

PatchDeepCopy returns an array that is identical to a given an array of patches.

(patches []Patch)

Source from the content-addressed store, hash-verified

210
211// PatchDeepCopy returns an array that is identical to a given an array of patches.
212func (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.
232func (dmp *DiffMatchPatch) PatchApply(patches []Patch, text string) (string, []bool) {

Callers 1

PatchApplyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected