Skip to content

Commit 2b962e9

Browse files
author
Nikita Kozlovskiy
committed
pass context to dyff to diaply the context of changes in multiline diffs
1 parent 1c05fd9 commit 2b962e9

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

diff/report.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ func printDyffReport(r *Report, to io.Writer) {
9090
_ = os.Remove(newFile.Name())
9191
}()
9292

93+
context := -1
9394
for _, entry := range r.Entries {
95+
context = entry.Context
9496
_, _ = currentFile.WriteString("---\n")
9597
_, _ = newFile.WriteString("---\n")
9698
for _, record := range entry.Diffs {
@@ -116,6 +118,11 @@ func printDyffReport(r *Report, to io.Writer) {
116118
OmitHeader: true,
117119
MinorChangeThreshold: 0.1,
118120
}
121+
122+
if context != -1 {
123+
reportWriter.MultilineContextLines = context
124+
}
125+
119126
_ = reportWriter.WriteReport(to)
120127
}
121128

0 commit comments

Comments
 (0)