@@ -361,8 +361,10 @@ export function createUnifiedDiff(
361361 language = 'plaintext' ,
362362 diffStyle = 'word' ,
363363 context = 10 ,
364+ ignoreMatchingLines ?: string ,
364365) : UnifiedViewerChange {
365366 const changes = diffLines ( oldString , newString )
367+ const ignoreRegex = ignoreMatchingLines ? new RegExp ( ignoreMatchingLines ) : undefined
366368
367369 let delNum = 0
368370 let addNum = 0
@@ -372,7 +374,7 @@ export function createUnifiedDiff(
372374 const result : UnifiedViewerChange = {
373375 changes : rawChanges ,
374376 collector : [ ] ,
375- stat : calcDiffStat ( changes ) ,
377+ stat : calcDiffStat ( changes , ignoreRegex ) ,
376378 }
377379
378380 for ( let i = 0 ; i < changes . length ; i ++ ) {
@@ -434,7 +436,11 @@ export function createUnifiedDiff(
434436 delNum ++
435437
436438 const code = getHighlightCode ( language , renderWords ( nextLine , curLine , diffStyle ) )
437- rawChanges . push ( { type : DiffType . DELETE , code, delNum } )
439+ rawChanges . push ( {
440+ type : ignoreRegex ?. test ( curLine ) ? DiffType . EQUAL : DiffType . DELETE ,
441+ code,
442+ delNum,
443+ } )
438444 }
439445
440446 for ( let j = 0 ; j < nextLines . length ; j ++ ) {
@@ -443,7 +449,11 @@ export function createUnifiedDiff(
443449 addNum ++
444450
445451 const code = getHighlightCode ( language , renderWords ( curLine , nextLine , diffStyle ) )
446- rawChanges . push ( { type : DiffType . ADD , code, addNum } )
452+ rawChanges . push ( {
453+ type : ignoreRegex ?. test ( nextLine ) ? DiffType . EQUAL : DiffType . ADD ,
454+ code,
455+ addNum,
456+ } )
447457 }
448458
449459 skip = true
0 commit comments