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

collapse-preserve-inline and throw #962

Closed
ainthek opened this issue Jul 3, 2016 · 2 comments
Closed

collapse-preserve-inline and throw #962

ainthek opened this issue Jul 3, 2016 · 2 comments

Comments

@ainthek
Copy link

ainthek commented Jul 3, 2016

I'm using js-beautify 1.6.3 on OSX for CLI formatting, main reason, to be cosnsitent with editor formatting (Sublime).
I have noticed that there is difference even if using same settings.
After digging deeper I have found theta runnting js-beautyfy twice from CLI, will give me what I expect.
Digging deeper 'throws' seems to cause trouble

echo 'if (a == 1) { a++; }' | js-beautify -b collapse-preserve-inline

prints expected

if (a == 1) { a++; }

however

echo 'if (a == 1) { throw "aaa" }' | js-beautify -b collapse-preserve-inline

prints unexpected (nor collapsed nor expanded version)

if (a == 1) {
    throw "aaa" }

why ?

and now the funny part (double formatting):

echo 'if (a == 1) { throw "aaa" }' | js-beautify -b collapse-preserve-inline | js-beautify -b collapse-preserve-inline 

prints:

if (a == 1) {
    throw "aaa"
}

so it is unstable and formatting result depends on how many times you run formatter ?

Thanx for help

@bitwiseman bitwiseman added this to the v1.6.4 milestone Jul 13, 2016
@bitwiseman
Copy link
Member

Hello, excellent bug report and details. I've added this to the next milestone.

@bitwiseman bitwiseman removed this from the v1.6.4 milestone Aug 7, 2016
@bitwiseman
Copy link
Member

Duplicate of #898

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

No branches or pull requests

2 participants