@@ -792,14 +792,16 @@ func formatRangeUnified(start, stop int) string {
792
792
793
793
// Unified diff parameters
794
794
type LineDiffParams struct {
795
- A []string // First sequence lines
796
- FromFile string // First file name
797
- FromDate string // First file time
798
- B []string // Second sequence lines
799
- ToFile string // Second file name
800
- ToDate string // Second file time
801
- Eol string // Headers end of line, defaults to LF
802
- Context int // Number of context lines
795
+ A []string // First sequence lines
796
+ FromFile string // First file name
797
+ FromDate string // First file time
798
+ B []string // Second sequence lines
799
+ ToFile string // Second file name
800
+ ToDate string // Second file time
801
+ Eol string // Headers end of line, defaults to LF
802
+ Context int // Number of context lines
803
+ AutoJunk bool // If true, use autojunking
804
+ IsJunkLine func (string )bool // How to spot junk lines
803
805
}
804
806
805
807
// Compare two sequences of lines; generate the delta as a unified diff.
@@ -841,6 +843,9 @@ func WriteUnifiedDiff(writer io.Writer, diff LineDiffParams) error {
841
843
842
844
started := false
843
845
m := NewMatcher (diff .A , diff .B )
846
+ if diff .AutoJunk || diff .IsJunkLine != nil {
847
+ m = NewMatcherWithJunk (diff .A , diff .B , diff .AutoJunk , diff .IsJunkLine )
848
+ }
844
849
for _ , g := range m .GetGroupedOpCodes (diff .Context ) {
845
850
if ! started {
846
851
started = true
@@ -973,6 +978,9 @@ func WriteContextDiff(writer io.Writer, diff LineDiffParams) error {
973
978
974
979
started := false
975
980
m := NewMatcher (diff .A , diff .B )
981
+ if diff .AutoJunk || diff .IsJunkLine != nil {
982
+ m = NewMatcherWithJunk (diff .A , diff .B , diff .AutoJunk , diff .IsJunkLine )
983
+ }
976
984
for _ , g := range m .GetGroupedOpCodes (diff .Context ) {
977
985
if ! started {
978
986
started = true
0 commit comments