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

Block formatting within function call parameters. #258

Closed
vkadam opened this issue May 8, 2013 · 3 comments
Closed

Block formatting within function call parameters. #258

vkadam opened this issue May 8, 2013 · 3 comments

Comments

@vkadam
Copy link

vkadam commented May 8, 2013

In case if block formatting is used for function call arguments, like shown in following example.

function test(arg1, arg2, arg3) {
    console.log(arguments);
}
test(
/*Argument 1*/
{
    "Value1": "1"
},
/*Argument 2*/
{
    "Value2": "2"
},
/*Argument 3*/
{
    "Value3"
});

After beautify this code is formatted like

function test(arg1, arg2, arg3) {
    console.log(arguments);
}
test(
/*Argument 1*/ {
    "Value1": "1"
},
/*Argument 2*/ {
    "Value2": "2"
},
/*Argument 3*/ {
    "Value3"
});

On next beautify this is again formatted like

function test(arg1, arg2, arg3) {
    console.log(arguments);
}
test(
/*Argument 1*/
{
    "Value1": "1"
},
/*Argument 2*/
{
    "Value2": "2"
},
/*Argument 3*/
{
    "Value3"
});

And keeps happening.

Expected: Keep first formatting one with block comment on new line.

Same thing happens one http://jsbeautifier.org/

@bitwiseman
Copy link
Member

Neat. This might be addressed by #259, but might not. I'll modify the test framework so we can this class of issues in the future.

bitwiseman added a commit to bitwiseman/js-beautify that referenced this issue May 9, 2013
beautifier#258 surfaced and interersting issue that was not caught by the
current test framework.  Now the framework checks that beautified
output is unchanged after being run through the beautifier again.

Adding this check immediately found a bug in the beautification of
function declarations. Fixed that as well.
@bitwiseman
Copy link
Member

Oh, fun with comments again. I have a fix for this case, but it fails this one:

function test(arg1, arg2, arg3) {
    console.log(arguments);
}
test(
/*Argument 1
*/
{
    "Value1": "1"
},
/*Argument 2
*/
{
    "Value2": "2"
},
/*Argument 3
*/
{
    "Value3"
});

bitwiseman added a commit that referenced this issue May 26, 2013
@vkadam
Copy link
Author

vkadam commented May 26, 2013

Thanks a lot. I will wait till its gets published at npm.

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