Mercurial Hosting > luan
changeset 1808:69623c62aa34
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 12 May 2024 15:58:30 -0600 |
parents | ffa28e2155bb |
children | 90187946d1a4 |
files | src/goodjava/util/LineDiff.java |
diffstat | 1 files changed, 7 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/goodjava/util/LineDiff.java Sun May 12 15:25:29 2024 -0600 +++ b/src/goodjava/util/LineDiff.java Sun May 12 15:58:30 2024 -0600 @@ -16,10 +16,10 @@ public final int line; public final String text; - private Diff(char operation,int line,String text) { + private Diff(char operation,String[] lines,int i) { this.operation = operation; - this.line = line; - this.text = text; + this.line = i+1; + this.text = lines[i]; } } @@ -67,22 +67,18 @@ iOld++; iNew++; } else if (opt[iOld+1][iNew] >= opt[iOld][iNew+1]) { - diffs.add( new Diff( DELETE, iOld+1, oldLines[iOld] ) ); - iOld++; + diffs.add( new Diff( DELETE, oldLines, iOld++ ) ); } else { - diffs.add( new Diff( INSERT, iOld+1, newLines[iNew] ) ); - iNew++; + diffs.add( new Diff( INSERT, newLines, iNew++ ) ); } } // dump out one remainder of one string if the other is exhausted while( iOld < nOld ) { - diffs.add( new Diff( DELETE, iOld+1, oldLines[iOld] ) ); - iOld++; + diffs.add( new Diff( DELETE, oldLines, iOld++ ) ); } while( iNew < nNew ) { - diffs.add( new Diff( INSERT, nOld+1, newLines[iNew] ) ); - iNew++; + diffs.add( new Diff( INSERT, newLines, iNew++ ) ); } return diffs;