Last Comment Bug 86093 - Tab chars in html source show up as "[]" (square) in Error Console
: Tab chars in html source show up as "[]" (square) in Error Console
Status: RESOLVED FIXED
:
Product: Core Graveyard
Classification: Graveyard
Component: Error Console (show other bugs)
: Trunk
: All All
-- normal (vote)
: ---
Assigned To: Simon Bünzli
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2001-06-15 09:15 PDT by Henrik Gemal
Modified: 2010-05-04 05:19 PDT (History)
8 users (show)
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
tab chars get shown as [] squares in console window (2.82 KB, image/gif)
2001-06-15 09:16 PDT, Henrik Gemal
no flags Details
patch to fix tabs and newlines (1.16 KB, patch)
2002-04-03 02:16 PST, Henrik Gemal
no flags Details | Diff | Splinter Review
patch version 2 (1.22 KB, patch)
2002-04-03 02:22 PST, Henrik Gemal
no flags Details | Diff | Splinter Review
better patch. now using a style (1.82 KB, patch)
2002-04-03 03:22 PST, Henrik Gemal
no flags Details | Diff | Splinter Review
replace all whitespace characters with spaces (2.73 KB, patch)
2006-07-14 03:28 PDT, Simon Bünzli
gavin.sharp: review+
neil: superreview+
Details | Diff | Splinter Review

Description User image Henrik Gemal 2001-06-15 09:15:58 PDT
If you have a warning or error in a line in a html document that contains a tab 
chars, the tab chars get shown as [] in the JavaScript console. ala:

Warning: redeclaration of var i
Source File: http://dev.gemal.dk/gemal.dk/en/browserspy/profile.html
Line: 23, Column: 13
Source Code:
[][]for (var i = 0; i < fields.length; i++)


Will attach screenshot:

Expected:
Either tabs should be removed or replaced by 2 spaces
Comment 1 User image Henrik Gemal 2001-06-15 09:16:30 PDT
Created attachment 38612 [details]
tab chars get shown as [] squares in console window
Comment 2 User image sairuh (rarely reading bugmail) 2001-06-15 10:25:13 PDT
->hewitt
Comment 3 User image Henrik Gemal 2001-10-22 10:22:56 PDT
\n chars are also shown as [] in the console.
Comment 4 User image Henrik Gemal 2002-04-03 02:16:02 PST
Created attachment 77426 [details] [diff] [review]
patch to fix tabs and newlines
Comment 5 User image Henrik Gemal 2002-04-03 02:22:10 PST
Created attachment 77428 [details] [diff] [review]
patch version 2
Comment 6 User image Daniel Brooks [:db48x] 2002-04-03 02:59:29 PST
Comment on attachment 77428 [details] [diff] [review]
patch version 2

>+            // get rid of newlines and tabs
>+            var sourcetext= aObject.sourceLine;

space before the =

>+            sourcetext = sourcetext.replace(/[\n|\r]/g, "");
>+            sourcetext = sourcetext.replace(/^\t*/g, "  ");
>+            sourcetext = sourcetext.replace(/\t/g, "  ");

I'd make it do this instead:
+	     sourcetext = sourcetext.replace(/\t/g, "  ");
+	     sourcetext = sourcetext.replace(/^\s*/, "");

and then change mozilla/xpfe/components/console/resources/content/console.css
so that the rule for .console-error-source has a margin-left to accomplish the
indentation

then it'll be r=db48x
Comment 7 User image Henrik Gemal 2002-04-03 03:22:15 PST
Created attachment 77434 [details] [diff] [review]
better patch. now using a style
Comment 8 User image Henrik Gemal 2002-04-03 03:29:08 PST
alecf: could you sr?
Comment 9 User image neil@parkwaycc.co.uk 2002-04-03 04:14:47 PST
Erm... if you fiddle about with tabs like that you'll kill the error marker :-(

Why not row.setAttribute("code", aObject.sourceLine.replace(/[\x00-\x1F]/g, " "));

[Aside: what was a dynamic regexp doing there?]
Comment 10 User image Alec Flett 2002-04-03 11:17:58 PST
let me know when this is sorted out. I'm not sure I agree with the replacement
of all characters < 0x1F though.

I don't know what tabs should be. I was going to suggest 8 spaces, myself :)
Comment 11 User image Daniel Brooks [:db48x] 2002-04-03 16:27:58 PST
the error marker isn't usually correct anyway, as both the code and the marker
are shown in a varible width font, so even if we know what character the error
was on, we can't line it up right. 

I say go ahead and check this patch in, and file the marker misalignment as a
seperate bug. (I'd also change it to display an <hr/> or just a border instead
of a bunch of dashes, so it would look prettier. That and the marker should
probably be indented the same was as the code so that it has a better chance of
lining up correctly.) 
Comment 12 User image neil@parkwaycc.co.uk 2002-04-04 00:39:56 PST
Actually the marker works fine in Classic, there's already a bug filed on that.
Comment 13 User image Simon Bünzli 2006-07-14 03:28:15 PDT
Created attachment 229232 [details] [diff] [review]
replace all whitespace characters with spaces

This patch simply replaces all whitespace characters which should prevent most of these irritating/useless squares (haven't seen any of them for over a year). The reason to replace every character with precisely one space is that otherwise the column marker will point to the wrong location since the column count is in plain characters.
Comment 14 User image Nickolay_Ponomarev 2007-02-28 23:18:41 PST
mozilla/toolkit/components/console/content/consoleBindings.xml         1.17
mozilla/xpfe/components/console/resources/content/consoleBindings.xml  1.29

Note You need to log in before you can comment on or make changes to this bug.