Fix whitespace errors with word diff enabled
Whitespace errors weren't being displayed if they occurred within a region that was highlighted for word difference on a line, due to the word difference HTML code preventing the patterns from matching. Bug: issue 445 Change-Id: If4f32352aa43d7517fe7cd3f20aa8982360800a0 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -381,15 +381,17 @@ public abstract class PrettyFormatter {
|
||||
}
|
||||
|
||||
private SafeHtml showTabAfterSpace(SafeHtml src) {
|
||||
src = src.replaceFirst("^( *\t)", "<span class=\"wse\">$1</span>");
|
||||
src = src.replaceAll("\n( *\t)", "\n<span class=\"wse\">$1</span>");
|
||||
final String m = "( ( |<span[^>]*>|</span>)*\t)";
|
||||
final String r = "<span class=\"wse\">$1</span>";
|
||||
src = src.replaceFirst("^" + m, r);
|
||||
src = src.replaceAll("\n" + m, "\n" + r);
|
||||
return src;
|
||||
}
|
||||
|
||||
private SafeHtml showTrailingWhitespace(SafeHtml src) {
|
||||
final String r = "<span class=\"wse\">$1</span>$2";
|
||||
src = src.replaceAll("([ \t][ \t]*)(\r?\n)", r);
|
||||
src = src.replaceFirst("([ \t][ \t]*)(\r?\n?)$", r);
|
||||
src = src.replaceAll("([ \t][ \t]*)(\r?(</span>)?\n)", r);
|
||||
src = src.replaceFirst("([ \t][ \t]*)(\r?(</span>)?\n?)$", r);
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,23 @@
|
||||
border-left: 1px dotted red;
|
||||
}
|
||||
|
||||
.wse .vt {
|
||||
border-left: 2px dotted black;
|
||||
}
|
||||
|
||||
.wdd {
|
||||
background: #FAA;
|
||||
}
|
||||
.wdi {
|
||||
background: #9F9;
|
||||
}
|
||||
|
||||
/* Use special rules for special styles contained within a whitespace
|
||||
* error. For these we want the whitespace error to take precedence
|
||||
* so we have to override the contained style.
|
||||
*/
|
||||
.wse .vt {
|
||||
border-left: 2px dotted black;
|
||||
}
|
||||
.wse .wdd {
|
||||
background: red;
|
||||
}
|
||||
.wse .wdi {
|
||||
background: red;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user