@@ -512,9 +512,27 @@ private function compare_arrays pA, pALength, pB, pBLength
512512
513513 end repeat
514514
515- return tPath [tDelta ]
515+ return add_content_to_edits( tPath [tDelta ], pA , pB )
516516end compare_arrays
517517
518+ private function add_content_to_edits pEdits, pA, pB
519+ local tEdits
520+ repeat for each line tEdit in pEdits
521+ local tA , tB , tOperation
522+ put item 2 of tEdit into tOperation
523+ local tContent
524+ if tOperation is kDiffOperationAdd then
525+ put item 3 of tEdit into tB
526+ put pB [tB ] into tContent
527+ else
528+ put item 1 of tEdit into tA
529+ put pA [tA ] into tContent
530+ end if
531+ put tEdit ,tContent & return after tEdits
532+ end repeat
533+ return tEdits
534+ end add_content_to_edits
535+
518536private command compare_diagonal @pFP, @pPath, @pA, pALength, @pB, pBLength, k
519537 local tLeft , tRight , tNext , tPrevPath , tOperation , tContent
520538 put pFP [k - 1 ] + 1 into tLeft
@@ -523,16 +541,14 @@ private command compare_diagonal @pFP, @pPath, @pA, pALength, @pB, pBLength, k
523541 put pPath [k - 1 ] into tPrevPath
524542 put kDiffOperationAdd into tOperation
525543 put tLeft into tNext
526- put pB [tNext ] into tContent
527544 else
528545 put pPath [k + 1 ] into tPrevPath
529546 put kDiffOperationDelete into tOperation
530547 put tRight into tNext
531- put pA [tNext - k] into tContent
532548 end if
533549
534550 if k > 0 or tNext > 0 then
535- put tPrevPath & format_edit( tNext - k, tNext , tOperation , tContent ) & return into pPath [k]
551+ put tPrevPath & tNext - k, tOperation ,tNext & cr into pPath [k]
536552 end if
537553 local tP
538554 put snake(pA , pALength , pB , pBLength , k, tNext ) into pFP [k]
0 commit comments