Fix bug in getDiffChunk()

The binary search was returning null when a line is part of a
diff chunk, causing regression in resizePaddingWidget() for
comment boxes. Fixed by adding an extra check.

Change-Id: I3b0e30173f8cea773d3804abc3ecfea4ef67123d
This commit is contained in:
Michael Zhou
2013-08-19 22:29:25 -07:00
parent 07e301e878
commit c14aaf915d

View File

@@ -1176,7 +1176,18 @@ public class SideBySide2 extends Screen {
diffChunks,
new DiffChunkInfo(side, line, 0, false), // Dummy DiffChunkInfo
getDiffChunkComparator());
return res >= 0 ? diffChunks.get(res) : null;
if (res >= 0) {
return diffChunks.get(res);
} else { // The line might be within a DiffChunk
res = -res - 1;
if (res > 0) {
DiffChunkInfo info = diffChunks.get(res - 1);
if (info.side == side && info.start <= line && line <= info.end) {
return info;
}
}
}
return null;
}
private int getWrapAroundDiffChunkIndex(int index) {