MCPcopy Create free account
hub / github.com/cogentcore/core / PlainReplace

Method PlainReplace

texteditor/difflib/difflib.go:612–626  ·  view source on GitHub ↗
(a []string, alo int, ahi int, b []string, blo int, bhi int)

Source from the content-addressed store, hash-verified

610}
611
612func (d *Differ) PlainReplace(a []string, alo int, ahi int, b []string, blo int, bhi int) (out []string, err error) {
613 if !(alo < ahi) || !(blo < bhi) { // assertion
614 return nil, errors.New("low greater than or equal to high")
615 }
616 // dump the shorter block first -- reduces the burden on short-term
617 // memory if the blocks are of very different sizes
618 if bhi-blo < ahi-alo {
619 out = d.Dump("+", b, blo, bhi)
620 out = append(out, d.Dump("-", a, alo, ahi)...)
621 } else {
622 out = d.Dump("-", a, alo, ahi)
623 out = append(out, d.Dump("+", b, blo, bhi)...)
624 }
625 return out, nil
626}
627
628func (d *Differ) FancyReplace(a []string, alo int, ahi int, b []string, blo int, bhi int) (out []string, err error) {
629 // When replacing one block of lines with another, search the blocks

Callers 2

TestDifferPlainReplaceFunction · 0.95
FancyReplaceMethod · 0.95

Calls 2

DumpMethod · 0.95
NewMethod · 0.65

Tested by 1

TestDifferPlainReplaceFunction · 0.76