feat: Improve diff being generated
Add `DiffCleanupSemantic` into the mix when generated diffs (PR review, commit view and issue/comment history). This avoids trying to produce a optimal diff and tries to reduce the amount of edits, by combing them into larger edits, which is nicer and easier to 'look at'. There's no need for a perfect minimal diff, as the output isn't being parsed by a computer, it's parsed by people. Ref: https://codeberg.org/forgejo/forgejo/issues/4996
This commit is contained in:
parent
d97e36f6d7
commit
58ee9fdc4a
2 changed files with 2 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue