sergi / go-diff

Diff, match and patch text in Go
MIT License
1.81k stars 207 forks source link

DiffPrettyText does does not colour all diffs with newlines #138

Open michaelcheah opened 1 year ago

michaelcheah commented 1 year ago

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