Tab chars in html source show up as "[]" (square) in Error Console

RESOLVED FIXED

Status

Core Graveyard
Error Console
RESOLVED FIXED
16 years ago
7 years ago

People

(Reporter: Henrik Gemal, Assigned: Simon Bünzli)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 3 obsolete attachments)

(Reporter)

Description

16 years ago
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
(Reporter)

Comment 1

16 years ago
Created attachment 38612 [details]
tab chars get shown as [] squares in console window
->hewitt
Assignee: pchen → hewitt

Updated

16 years ago
Status: NEW → ASSIGNED

Updated

16 years ago
Priority: -- → P5
Target Milestone: --- → Future
Component: XP Apps → JavaScript Console
QA Contact: sairuh → jrgm
(Reporter)

Comment 3

16 years ago
\n chars are also shown as [] in the console.
(Reporter)

Comment 4

15 years ago
Created attachment 77426 [details] [diff] [review]
patch to fix tabs and newlines
(Reporter)

Updated

15 years ago
Keywords: patch, review
(Reporter)

Comment 5

15 years ago
Created attachment 77428 [details] [diff] [review]
patch version 2
Attachment #77426 - Attachment is obsolete: true
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
Attachment #77428 - Flags: needs-work+
(Reporter)

Comment 7

15 years ago
Created attachment 77434 [details] [diff] [review]
better patch. now using a style
Attachment #77428 - Attachment is obsolete: true
(Reporter)

Comment 8

15 years ago
alecf: could you sr?

Comment 9

15 years ago
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

15 years ago
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 :)
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

15 years ago
Actually the marker works fine in Classic, there's already a bug filed on that.

Updated

11 years ago
Summary: Tab chars in html source show up as "[]" (square) in JavaScript console → Tab chars in html source show up as "[]" (square) in Error Console
(Assignee)

Comment 13

11 years ago
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.
Attachment #229232 - Flags: superreview?(neil)
Attachment #229232 - Flags: review?(mconnor)
(Assignee)

Updated

11 years ago
Target Milestone: Future → ---

Updated

11 years ago
Attachment #229232 - Flags: superreview?(neil) → superreview+
Assignee: hewitt → zeniko
Status: ASSIGNED → NEW
Priority: P5 → --
QA Contact: jrgmorrison → error-console
(Assignee)

Updated

10 years ago
Attachment #229232 - Flags: review?(mconnor) → review?(gavin.sharp)
Attachment #229232 - Flags: review?(gavin.sharp) → review+
Whiteboard: [checkin needed]

Comment 14

10 years ago
mozilla/toolkit/components/console/content/consoleBindings.xml         1.17
mozilla/xpfe/components/console/resources/content/consoleBindings.xml  1.29
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]

Updated

10 years ago
Attachment #77434 - Attachment is obsolete: true
Product: Core → SeaMonkey

Updated

7 years ago
Component: Error Console → Error Console
Product: SeaMonkey → Core Graveyard
You need to log in before you can comment on or make changes to this bug.