go-diff icon indicating copy to clipboard operation
go-diff copied to clipboard

DiffPrettyText does does not colour all diffs with newlines

Open michaelcheah opened this issue 1 year ago • 0 comments

Using the following example:

dmp := New()
diffs := dmp.DiffMain("a\nb\nc\ndef\ni", "a\ndef\ng\nh\ni", false)

Produces the following diffs:

diff2 := []Diff{
	{Type:DiffEqual, Text:"a\n"}, 
	{Type:DiffDelete, Text:"b\nc\n"}, 
	{Type:DiffEqual, Text:"def"}, 
	{Type:DiffInsert, Text:"\ng\nh"}, 
	{Type:DiffEqual, Text:"\ni"},
}

Pretty printing to stdout

fmt.Println(dmp.DiffPrettyText(diffs))

Produces the following stdout image

However, I expected: image

michaelcheah avatar Mar 24 '23 19:03 michaelcheah