Fix yet another ArrayIndexOutOfBounds during side-by-side view

We messed up the mapping when converting from side B line numbers
to side A line numbers, resulting in an EMPTY edit being placed
too early in a file when it fell between two INSERT edits.  This
had the effect of making Gerrit skip over an entire INSERT, which
then threw off the line numbering on the B side when creating the
side-by-side or unified view for certain files.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-08-12 11:41:18 -07:00
parent 33b19959d6
commit c059790c71
2 changed files with 7 additions and 5 deletions

View File

@@ -138,7 +138,7 @@ public class EditList {
}
public boolean isContextLine() {
return !isModifiedLine() || endIdx + 1 < curIdx;
return !isModifiedLine();
}
public boolean isDeletedA() {
@@ -154,8 +154,10 @@ public class EditList {
}
public boolean next() {
if (!in(curEdit) && ++curIdx < edits.size()) {
curEdit = edits.get(curIdx);
if (!in(curEdit)) {
if (curIdx < endIdx) {
curEdit = edits.get(++curIdx);
}
}
return aCur < aEnd || bCur < bEnd;
}

View File

@@ -271,7 +271,7 @@ class PatchScriptBuilder {
//
return a;
}
return edits.get(i - i).getEndB() + (e.getBeginA() - a);
return e.getBeginB() - (e.getBeginA() - a);
}
if (e.getBeginA() <= a && a <= e.getEndA()) {
return -1;
@@ -297,7 +297,7 @@ class PatchScriptBuilder {
//
return b;
}
return edits.get(i - i).getEndA() + (e.getBeginB() - b);
return e.getBeginA() - (e.getBeginB() - b);
}
if (e.getBeginB() <= b && b <= e.getEndB()) {
return -1;