diff options
author | Doug Kelly <doug.kelly@garmin.com> | 2013-10-02 17:49:49 -0500 |
---|---|---|
committer | Doug Kelly <doug.kelly@garmin.com> | 2013-10-07 15:15:38 -0500 |
commit | b3d0cc4c2a2dcbdc1f9fecee080ab969c513990a (patch) | |
tree | c2f826e9aa6586ebb2795c8c0499fe2ea6a0c316 | |
parent | 62f5438bdb86052bef43c59011422759f257a236 (diff) |
Prevent expansion when whole file isn't loaded
This prevents attempting to expand lines which aren't returned by
the SparseFileContents in the event the whole file hasn't been
loaded. This can happen any time syntax highlighting is off (and
the whole file context isn't selected), or when the file is huge
(>9000 lines). Since a huge file disables syntax highlighting and
forces a maximum of 25 lines context, it doesn't make sense to
taunt the user with lines they can't see.
Bug: Issue 1233
Change-Id: I3dc58e934da20f63a1f23d764f50abb5230ed1ee
-rw-r--r-- | gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java index 15ab951e9e..350c63981d 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java @@ -203,7 +203,7 @@ public class SideBySideTable extends AbstractPatchContentTable { for (int row = 0; row < lines.size(); row++) { setRowItem(row, lines.get(row)); if (lines.get(row) instanceof SkippedLine) { - createSkipLine(row, (SkippedLine) lines.get(row)); + createSkipLine(row, (SkippedLine) lines.get(row), script.getA().isWholeFile()); } } } @@ -503,16 +503,18 @@ public class SideBySideTable extends AbstractPatchContentTable { if (numRows > 0) { line.incrementStart(numRows); - createSkipLine(row + loopTo, line); + // If we got here, we must have the whole file anyway. + createSkipLine(row + loopTo, line, true); } else if (numRows < 0) { line.reduceSize(-numRows); - createSkipLine(row, line); + // If we got here, we must have the whole file anyway. + createSkipLine(row, line, true); } else { table.removeRow(row + loopTo); } } - private void createSkipLine(int row, SkippedLine line) { + private void createSkipLine(int row, SkippedLine line, boolean isWholeFile) { FlowPanel p = new FlowPanel(); InlineLabel l1 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionStart() + " "); InlineLabel l2 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionEnd() + " "); @@ -521,7 +523,7 @@ public class SideBySideTable extends AbstractPatchContentTable { all.addClickHandler(expandAllListener); all.setStyleName(Gerrit.RESOURCES.css().skipLine()); - if (line.getSize() > 30) { + if (line.getSize() > 30 && isWholeFile) { // Only show the expand before/after if skipped more than 30 lines. Anchor b = new Anchor(PatchUtil.M.expandBefore(NUM_ROWS_TO_EXPAND), true); Anchor a = new Anchor(PatchUtil.M.expandAfter(NUM_ROWS_TO_EXPAND), true); @@ -537,10 +539,14 @@ public class SideBySideTable extends AbstractPatchContentTable { p.add(all); p.add(l2); p.add(a); - } else { + } else if (isWholeFile) { p.add(l1); p.add(all); p.add(l2); + } else { + p.add(l1); + p.add(new InlineLabel(" " + line.getSize() + " ")); + p.add(l2); } table.setWidget(row, 1, p); } |