Don't aggressively coalesce across lines
Don't bother trying to coalesce over line boundaries when the common region that contains the LF is less than 5 characters. Its likely that the common region is actually a trailing "*/" or "}" to close out the current statement. We are usually better off reporting this as common to the user. Bug: issue 473 Change-Id: I93762d07d34eb71269ea6758ac3466a5351f8dbf Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -246,9 +246,12 @@ public class PatchListCacheImpl implements PatchListCache {
|
|||||||
int bb = c.getBeginB();
|
int bb = c.getBeginB();
|
||||||
int be = n.getEndB();
|
int be = n.getEndB();
|
||||||
|
|
||||||
wordEdits.set(j, new Edit(ab, ae, bb, be));
|
if (canCoalesce(a, c.getEndA(), n.getBeginA())
|
||||||
wordEdits.remove(j + 1);
|
&& canCoalesce(b, c.getEndB(), n.getBeginB())) {
|
||||||
continue;
|
wordEdits.set(j, new Edit(ab, ae, bb, be));
|
||||||
|
wordEdits.remove(j + 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j++;
|
j++;
|
||||||
@@ -367,6 +370,15 @@ public class PatchListCacheImpl implements PatchListCache {
|
|||||||
return new PatchListEntry(fileHeader, edits);
|
return new PatchListEntry(fileHeader, edits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean canCoalesce(CharText a, int b, int e) {
|
||||||
|
while (b < e) {
|
||||||
|
if (a.charAt(b++) == '\n') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static int findLF(List<Edit> edits, int j, CharText t, int b) {
|
private static int findLF(List<Edit> edits, int j, CharText t, int b) {
|
||||||
int lf = b;
|
int lf = b;
|
||||||
int limit = 0 < j ? edits.get(j - 1).getEndB() : 0;
|
int limit = 0 < j ? edits.get(j - 1).getEndB() : 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user