SideBySide2: Gracefully handle skipped regions from server

If the server sends a content block as {"skip": 20} there are
20 lines in common between both a and b and the server has not
sent this text to the browser. This should be skipped over in
both the chunk manager and skip manager.

Change-Id: I1d8ec6255d2679cb0602278e6a16eb22172b9694
This commit is contained in:
Shawn Pearce
2014-01-21 13:03:10 -08:00
parent e2313239d4
commit 6d7b33121b
2 changed files with 6 additions and 2 deletions

View File

@@ -105,6 +105,8 @@ class ChunkManager {
for (Region current : Natives.asList(diff.content())) {
if (current.ab() != null) {
mapper.appendCommon(current.ab().length());
} else if (current.skip() > 0) {
mapper.appendCommon(current.skip());
} else if (current.common()) {
mapper.appendCommon(current.b().length());
} else {

View File

@@ -52,8 +52,10 @@ class SkipManager {
int lineA = 0, lineB = 0;
for (int i = 0; i < regions.length(); i++) {
Region current = regions.get(i);
if (current.ab() != null || current.common()) {
int len = (current.ab() != null ? current.ab() : current.b()).length();
if (current.ab() != null || current.common() || current.skip() > 0) {
int len = current.skip() > 0
? current.skip()
: (current.ab() != null ? current.ab() : current.b()).length();
if (i == 0 && len > context + 1) {
skips.add(new SkippedLine(0, 0, len - context));
} else if (i == regions.length() - 1 && len > context + 1) {