Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line breaks immediately followed by ANSI escapes are swallowed #262

Closed
bruderstein opened this issue Sep 13, 2015 · 2 comments
Closed

Line breaks immediately followed by ANSI escapes are swallowed #262

bruderstein opened this issue Sep 13, 2015 · 2 comments
Labels

Comments

@bruderstein
Copy link

Using unexpected, and the new ANSI escape sequence parsing in wallaby (issue #237), wallaby displays the full colour error message.

However, when a newline is immediately followed by an escape code, the newline is swallowed.

Compare:
uenxpected_break

with the same test run on the console (unexpected is actually intellegent about the line breaks, so this is on a narrower console, if the console is wider, there's just a space, not sure if that has something to do with it, but the mock tests in the demo below would suggest not)

console_break

I've mocked out the UnexpectedError object to try and work out exactly when they're swallowed, and it appears to be when an escape code immediately follows the new line.

A demo is at bruderstein/wallaby-ansi-parser

One "real" test is included, where the difference between running npm test in the console and running it in wallaby can be seen.

3 small "mock" tests that only really work in wallaby also show the difference a single space makes following the line break.

   it('shows line breaks when lines begin with letter', function () {
       throw new UnexpectedError('\x1b[32mLine one\nLine two\x1b[39m');
   });

    it('swallows line breaks when lines begin with ansi code', function () {
        throw new UnexpectedError('\x1b[32mLine one\nLine two\x1b[39m\n\x1b[31mLine 3\x1b[39m');
    });

    it('a simple space is enough to keep the line break', function () {
        throw new UnexpectedError('\x1b[32mLine one\nLine two\x1b[39m\n \x1b[31mLine 3\x1b[39m');
    });

mocktests

Wallaby IntelliJ plugin 1.0.28
Wallaby core 1.0.104
WebStorm 11 (142.4148), Linux

Thank you :)

@ArtemGovorov
Copy link
Member

Thanks a lot for the demo repo and the analysis on when exactly the issue is reproduced!
It's now fixed in Wallaby IntelliJ plugin v1.0.29.

@bruderstein
Copy link
Author

Wow, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants