Skip to content
Browse files

Issue 6130: Text copied from console has lots of line breaks

  • Loading branch information...
1 parent db43836 commit 3cce67766f59141fab1e8cd949510a1e660a4e3d @simonlindholm committed Apr 1, 2013
Showing with 35 additions and 2 deletions.
  1. +33 −1 extension/content/firebug/chrome/reps.js
  2. +2 −1 extension/content/firebug/console/consolePanel.js
View
34 extension/content/firebug/chrome/reps.js
@@ -57,8 +57,10 @@ catch (err)
// ********************************************************************************************* //
// Common Tags
-// use pre here to keep line breaks while copying multiline strings
var OBJECTBOX = FirebugReps.OBJECTBOX =
+ SPAN({"class": "objectBox objectBox-$className", role: "presentation"});
+
+var PREOBJECTBOX =
PRE({"class": "objectBox inline objectBox-$className", role: "presentation"});
var OBJECTBLOCK = FirebugReps.OBJECTBLOCK =
@@ -142,6 +144,27 @@ FirebugReps.Number = domplate(Firebug.Rep,
// ********************************************************************************************* //
+// To support copying strings with multiple spaces, tabs, newlines etc. correctly
+// we are unfortunately required by Firefox to use a <pre> tag (bug 116083).
+// Don't do that with all OBJECTBOX's though - it inserts newlines *everywhere*.
+// (See issues 3816, 6130.)
+var reWeirdWhitespace = / |[\t\n]/;
+FirebugReps.WeirdWhitespaceString = domplate(Firebug.Rep,
+{
+ tag: PREOBJECTBOX("&quot;$object&quot;"),
+
+ shortTag: OBJECTBOX("&quot;$object|cropMultipleLines&quot;"),
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ className: "string",
+
+ supportsObject: function(object, type)
+ {
+ return (type == "string" && reWeirdWhitespace.test(object));
+ }
+});
+
FirebugReps.String = domplate(Firebug.Rep,
{
tag: OBJECTBOX("&quot;$object&quot;"),
@@ -192,8 +215,16 @@ FirebugReps.Text = domplate(Firebug.Rep,
{
tag: OBJECTBOX("$object"),
+ // Refer to WeirdWhitespaceString above.
+ weirdWhitespaceTag: PREOBJECTBOX("$object"),
+
shortTag: OBJECTBOX("$object|cropMultipleLines"),
+ getWhitespaceCorrectedTag: function(str)
+ {
+ return reWeirdWhitespace.test(str) ? this.weirdWhitespaceTag : this.tag;
+ },
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
className: "text"
@@ -3404,6 +3435,7 @@ Firebug.registerRep(
FirebugReps.Undefined,
FirebugReps.Null,
FirebugReps.Number,
+ FirebugReps.WeirdWhitespaceString,
FirebugReps.String,
FirebugReps.nsIDOMHistory, // make this early to avoid exceptions
FirebugReps.ApplicationCache, // this also
View
3 extension/content/firebug/console/consolePanel.js
@@ -599,7 +599,8 @@ Firebug.ConsolePanel.prototype = Obj.extend(Firebug.ActivablePanel,
}
else
{
- node = FirebugReps.Text.tag.append({object: part}, row);
+ var tag = FirebugReps.Text.getWhitespaceCorrectedTag(part);
+ node = tag.append({object: part}, row);
}
// Apply custom style if available.

0 comments on commit 3cce677

Please sign in to comment.
Something went wrong with that request. Please try again.