sergi / go-diff

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

DiffMain does not show deleted space #96

Open mingrammer opened 5 years ago

mingrammer commented 5 years ago
package main

import (
    "fmt"

    "github.com/sergi/go-diff/diffmatchpatch"
)

const (
    text1 = "package casec"
    text2 = "PackageCasec"
)

func main() {
    dmp := diffmatchpatch.New()

    diffs := dmp.DiffMain(text1, text2, false)

    fmt.Println(dmp.DiffPrettyText(diffs))
}

I expected the diff output results for above code to be one of pPackagecCasec or pPackage[x]cCasec, but it printed pPackage cCasec instead. ([x] indecates a space letter with red background)

So it was a little hard for me to recognize the space was deleted or not. I think DiffMain also should show the status of added or deleted space letters. I think it could be achieved using "space letter with a red or green background".