diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go index 31d2de6d53..16b250abda 100644 --- a/routers/web/repo/issue_content_history.go +++ b/routers/web/repo/issue_content_history.go @@ -154,6 +154,7 @@ func GetContentHistoryDetail(ctx *context.Context) { dmp := diffmatchpatch.New() // `checklines=false` makes better diff result diff := dmp.DiffMain(prevHistoryContentText, history.ContentText, false) + diff = dmp.DiffCleanupSemantic(diff) diff = dmp.DiffCleanupEfficiency(diff) // use chroma to render the diff html diff --git a/services/gitdiff/highlightdiff.go b/services/gitdiff/highlightdiff.go index 99313c5f36..c72959ea16 100644 --- a/services/gitdiff/highlightdiff.go +++ b/services/gitdiff/highlightdiff.go @@ -97,6 +97,7 @@ func (hcd *HighlightCodeDiff) diffWithHighlight(filename, language, codeA, codeB convertedCodeB := hcd.ConvertToPlaceholders(string(highlightCodeB)) diffs := diffMatchPatch.DiffMain(convertedCodeA, convertedCodeB, true) + diffs = diffMatchPatch.DiffCleanupSemantic(diffs) diffs = diffMatchPatch.DiffCleanupEfficiency(diffs) for i := range diffs {