Fix intraline difference off-by-one when LF is added

If a region starts or ends with an LF we incorrectly shifted the
entire edit right by one character.  This meant the LF that was
modified didn't get colored, but the first common character after
the edit was colored incorrectly.  Only try to shift left if the
region doesn't start with LF.

Change-Id: I46bbfaf69c4e509328a10ab5a67fcc7cf6493abd
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-03-01 12:16:07 -08:00
parent 7bfcf9ac59
commit 5942029b81

View File

@@ -291,7 +291,7 @@ public class PatchListCacheImpl implements PatchListCache {
boolean aShiftRight = true;
if (ab < ae && isOnlyWhitespace(a, ab, ae)) {
int lf = findLF(wordEdits, j, a, ab);
if (a.charAt(lf) == '\n') {
if (lf < ab && a.charAt(lf) == '\n') {
int nb = lf + 1;
int p = 0;
while (p < ae - ab) {
@@ -320,7 +320,7 @@ public class PatchListCacheImpl implements PatchListCache {
boolean bShiftRight = true;
if (bb < be && isOnlyWhitespace(b, bb, be)) {
int lf = findLF(wordEdits, j, b, bb);
if (b.charAt(lf) == '\n') {
if (lf < bb && b.charAt(lf) == '\n') {
int nb = lf + 1;
int p = 0;
while (p < be - bb) {