Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

fix issue where color formatting text is leaking #1216

Closed
wants to merge 1 commit into from

Conversation

hankduan
Copy link
Contributor

See #1131

@@ -310,11 +310,17 @@ TaskReporter_.prototype.log_ = function(data) {
for ( var i = 0; i < data.length; i++ ) {
if (this.insertTag) {
this.insertTag = false;
if (data[i] === '\x1B' && data.substring(i, i+4) === '\x1B[0m' ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment here on what this craziness is doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, jasmines sends back colored strings as:

\x1B[31mSome text\n\x1B[0mnew line

which gets formatted into

[color]Some text[/color]
[no color]new line[/no color]

However, if you simply add a new tag after the \n, the \x1B[0m appears before the text (and after the tag) in the new line. This is not an issue if you are using console or something that process the \x1B[0m properly. But if the \x1B[0m is not processed, then the \x1B[0m becomes concatenated with the info.

This craziness basically append the tag only after the \x1B[0m.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another note, technically data.substring(i, i+4) === '\x1B[0m' is all that's needed to do the job, but I did data[i] === '\x1B' && data.substring(i, i+4) === '\x1B[0m' as a slight optimization to avoid running a substring on every character.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I mean add a comment to the actual code so that we'll know what's going on in 2 months.

@juliemr juliemr added cla: yes and removed cla: no labels Aug 20, 2014
@juliemr juliemr added this to the 1.1.0 milestone Aug 20, 2014
@hankduan
Copy link
Contributor Author

added comment

@juliemr
Copy link
Member

juliemr commented Aug 20, 2014

LGTM

@hankduan
Copy link
Contributor Author

committed with 9814af1

@hankduan hankduan closed this Aug 20, 2014
@hankduan hankduan deleted the fix_report_color branch October 6, 2014 19:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants