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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user