summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-06-03 16:49:30 -0700
committerShawn O. Pearce <sop@google.com>2009-06-03 16:49:30 -0700
commite6153dc8dfcdb5e690316ca93e698ebd637223bb (patch)
tree220886c1caae434b2b07e2dac7b4e4e282588ddc
parent333dd59de53d99e51b1d1fc9ba3a5c876c362339 (diff)
Fix n/p on a file with only one edit
Back in 8724604fa9 ("Make n/p only honor comments on add/delete") I tried to teach n/p keyboard shortcuts to jump to comments when the change is the addition of a file, or the deletion of a file, as the entire thing is one giant edit list. Unfortunately this was based around just having 1 edit, and not checking the *type* of the file change, so n/p broke when there was exactly one region affected in the file. We now only match comments if there is exactly one hunk and either side of the patch script is empty (indicating full add or delete). Bug: GERRIT-213 Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java11
-rw-r--r--src/main/java/com/google/gerrit/client/patches/SideBySideTable.java2
-rw-r--r--src/main/java/com/google/gerrit/client/patches/UnifiedDiffTable.java2
3 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java b/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java
index 229f60ff17..ce620f1e84 100644
--- a/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java
+++ b/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java
@@ -26,6 +26,7 @@ import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.data.AccountInfoCache;
import com.google.gerrit.client.data.PatchScript;
import com.google.gerrit.client.data.PatchSetDetail;
+import com.google.gerrit.client.data.SparseFileContent;
import com.google.gerrit.client.reviewdb.Change;
import com.google.gerrit.client.reviewdb.Patch;
import com.google.gerrit.client.reviewdb.PatchLineComment;
@@ -174,6 +175,16 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
return null;
}
+ protected void initScript(final PatchScript script) {
+ if (script.getEdits().size() == 1) {
+ final SparseFileContent a = script.getA();
+ final SparseFileContent b = script.getB();
+ onlyOneHunk = a.size() == 0 || b.size() == 0;
+ } else {
+ onlyOneHunk = false;
+ }
+ }
+
private boolean isChunk(final int row) {
final Object o = getRowItem(row);
if (!onlyOneHunk && o instanceof PatchLine) {
diff --git a/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java b/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java
index 1edf12a42e..9a77424ef7 100644
--- a/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java
+++ b/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java
@@ -121,7 +121,7 @@ public class SideBySideTable extends AbstractPatchContentTable {
appendSkipLine(nc, b.size() - lastB);
}
resetHtml(nc);
- onlyOneHunk = script.getEdits().size() == 1;
+ initScript(script);
for (int row = 0; row < lines.size(); row++) {
setRowItem(row, lines.get(row));
diff --git a/src/main/java/com/google/gerrit/client/patches/UnifiedDiffTable.java b/src/main/java/com/google/gerrit/client/patches/UnifiedDiffTable.java
index 830f433d9b..9fad61b46e 100644
--- a/src/main/java/com/google/gerrit/client/patches/UnifiedDiffTable.java
+++ b/src/main/java/com/google/gerrit/client/patches/UnifiedDiffTable.java
@@ -119,7 +119,7 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
}
}
resetHtml(nc);
- onlyOneHunk = script.getEdits().size() == 1;
+ initScript(script);
int row = script.getPatchHeader().size();
final CellFormatter fmt = table.getCellFormatter();