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