summaryrefslogtreecommitdiffstats
path: root/extensions/Splinter
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2012-08-01 07:42:37 +0200
committerByron Jones <bjones@mozilla.com>2012-08-01 07:42:37 +0200
commit705479fe81066c23bc4e726c9914531a045b7f3c (patch)
tree7f33cd3d5413f28f9c743673c1b9254f70c4894f /extensions/Splinter
parentd93a8d2b8433a2ea47a97a6d9cb75408206d9e60 (diff)
downloadbugzilla-705479fe81066c23bc4e726c9914531a045b7f3c.tar.gz
bugzilla-705479fe81066c23bc4e726c9914531a045b7f3c.tar.xz
Bug 776897: highlight trailing whitespace in splinter
Diffstat (limited to 'extensions/Splinter')
-rw-r--r--extensions/Splinter/web/splinter.css4
-rw-r--r--extensions/Splinter/web/splinter.js18
2 files changed, 20 insertions, 2 deletions
diff --git a/extensions/Splinter/web/splinter.css b/extensions/Splinter/web/splinter.css
index 3f2eb84fe..014751b08 100644
--- a/extensions/Splinter/web/splinter.css
+++ b/extensions/Splinter/web/splinter.css
@@ -413,3 +413,7 @@ div.review-patch-comment-text {
.file-reviewed-nav {
text-decoration: line-through;
}
+
+.trailing-whitespace {
+ background: #ffaaaa;
+}
diff --git a/extensions/Splinter/web/splinter.js b/extensions/Splinter/web/splinter.js
index dee51d4a7..505decd47 100644
--- a/extensions/Splinter/web/splinter.js
+++ b/extensions/Splinter/web/splinter.js
@@ -1716,6 +1716,20 @@ Splinter.EL = function (element, cls, text, title) {
return e;
};
+Splinter.textTD = function (cls, text, title) {
+ if (text == "") {
+ return Splinter.EL("td", cls, "\u00a0", title);
+ }
+ var m = text.match(/^(.*?)(\s+)$/);
+ if (m) {
+ var td = Splinter.EL("td", cls, m[1], title);
+ td.insertBefore(Splinter.EL("span", cls + " trailing-whitespace", m[2], title), null);
+ return td;
+ } else {
+ return Splinter.EL("td", cls, text, title);
+ }
+}
+
Splinter.getElementPosition = function (element) {
var left = element.offsetLeft;
var top = element.offsetTop;
@@ -1841,7 +1855,7 @@ Splinter.appendPatchHunk = function (file, hunk, tableType, includeComments, cli
if (tableType != Splinter.Patch.ADDED) {
if (oldText != null) {
tr.appendChild(Splinter.EL("td", "line-number", oldLine.toString(), title));
- tr.appendChild(Splinter.EL("td", "old-line " + oldStyle, oldText != "" ? oldText : "\u00a0", title));
+ tr.appendChild(Splinter.textTD("old-line " + oldStyle, oldText, title));
oldLine++;
} else {
tr.appendChild(Splinter.EL("td", "line-number"));
@@ -1856,7 +1870,7 @@ Splinter.appendPatchHunk = function (file, hunk, tableType, includeComments, cli
if (tableType != Splinter.Patch.REMOVED) {
if (newText != null) {
tr.appendChild(Splinter.EL("td", "line-number", newLine.toString(), title));
- tr.appendChild(Splinter.EL("td", "new-line " + newStyle, newText != "" ? newText : "\u00a0", title));
+ tr.appendChild(Splinter.textTD("new-line " + newStyle, newText, title));
newLine++;
} else if (tableType == Splinter.Patch.CHANGED) {
tr.appendChild(Splinter.EL("td", "line-number"));