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

Method QFormat

texteditor/difflib/difflib.go:749–770  ·  view source on GitHub ↗
(aline string, bline string, atags string, btags string)

Source from the content-addressed store, hash-verified

747}
748
749func (d *Differ) QFormat(aline string, bline string, atags string, btags string) (out []string) {
750 // Format "?" output and deal with leading tabs.
751
752 // Can hurt, but will probably help most of the time.
753 common := min(count_leading(aline, '\t'), count_leading(bline, '\t'))
754 common = min(common, count_leading(atags[:common], ' '))
755 common = min(common, count_leading(btags[:common], ' '))
756 atags = strings.TrimRightFunc(atags[common:], unicode.IsSpace)
757 btags = strings.TrimRightFunc(btags[common:], unicode.IsSpace)
758
759 out = []string{"- " + aline}
760 if len(atags) > 0 {
761 out = append(out, fmt.Sprintf("? %s%s\n",
762 strings.Repeat("\t", common), atags))
763 }
764 out = append(out, "+ "+bline)
765 if len(btags) > 0 {
766 out = append(out, fmt.Sprintf("? %s%s\n",
767 strings.Repeat("\t", common), btags))
768 }
769 return out
770}
771
772// Convert range to the "ed" format
773func formatRangeUnified(start, stop int) string {

Callers 2

TestDifferQFormatFunction · 0.95
FancyReplaceMethod · 0.95

Calls 1

count_leadingFunction · 0.70

Tested by 1

TestDifferQFormatFunction · 0.76