Fix PatchScript's mapping of lines below the last edit
For comments below the last edit block of a PatchScript, the formulae to obtain the line number shifts between sides subtracted one side's end, but added the other side's beginning (instead of also the end). This mismatch could cause the client to fetch lines beyond a file's end and thereby cause an ArrayIndexofBoundException. We now use the difference of the last edit block's ends to map lines below the last edit. Change-Id: I67d2baa0f5ede3af7348c609034de81e8acf9c17
This commit is contained in:
@@ -346,7 +346,7 @@ class PatchScriptBuilder {
|
||||
}
|
||||
|
||||
final Edit last = edits.get(edits.size() - 1);
|
||||
return last.getBeginB() + (a - last.getEndA());
|
||||
return last.getEndB() + (a - last.getEndA());
|
||||
}
|
||||
|
||||
private int mapB2A(final int b) {
|
||||
@@ -372,7 +372,7 @@ class PatchScriptBuilder {
|
||||
}
|
||||
|
||||
final Edit last = edits.get(edits.size() - 1);
|
||||
return last.getBeginA() + (b - last.getEndB());
|
||||
return last.getEndA() + (b - last.getEndB());
|
||||
}
|
||||
|
||||
private void packContent(boolean ignoredWhitespace) {
|
||||
|
||||
Reference in New Issue
Block a user