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 wrap breaks signed numbers #2251

Open
rixls opened this issue Feb 23, 2024 · 1 comment
Open

Line wrap breaks signed numbers #2251

rixls opened this issue Feb 23, 2024 · 1 comment

Comments

@rixls
Copy link

rixls commented Feb 23, 2024

Description

At the end of the 1st line in the Actual Output we see a stray hyphen which belongs to the Number wrapped to the line after.

Input

[-0.49673205000000004, -0.49038462, -0.006536000000000042, -0.336538, 0.49673199999999995, -0.5, 0.40522899999999995, 0, 0.11764699999999995, -0.05769200000000002, -0.006536000000000042, 0.5, -0.03268000000000004, -0.19230799999999998, -0.42483660000000006, 0]

Expected Output

[-0.49673205000000004, -0.49038462, -0.006536000000000042, -0.336538, 0.49673199999999995, -0.5, 0.40522899999999995, 0, 0.11764699999999995,
    -0.05769200000000002, -0.006536000000000042, 0.5, -0.03268000000000004, -0.19230799999999998, -0.42483660000000006, 0
]

Actual Output

[-0.49673205000000004, -0.49038462, -0.006536000000000042, -0.336538, 0.49673199999999995, -0.5, 0.40522899999999995, 0, 0.11764699999999995, -
    0.05769200000000002, -0.006536000000000042, 0.5, -0.03268000000000004, -0.19230799999999998, -0.42483660000000006, 0
]

Steps to Reproduce

input = JSON.stringify([-0.49673205000000004, -0.49038462, -0.006536000000000042, -0.336538, 0.49673199999999995, -0.5, 0.40522899999999995, 0, 0.11764699999999995, -0.05769200000000002, -0.006536000000000042, 0.5, -0.03268000000000004, -0.19230799999999998, -0.42483660000000006, 0]);
console.log(js_beautify(input, { wrap_line_length: 160 }));

Environment

OS: Win10
Node: 20.7.0
js-beautify: 1.15.1 from cdnjs

Settings

{
    "wrap_line_length": 160
}
@robert-dodier
Copy link

I just bumped into this in the Python version (jsbeautifier). It wouldn't matter except that the JSON spec apparently disallows whitespace between the sign and the rest of a number; I wouldn't have noticed except that Python's json.load complains about it. Thank you for your attention to this.

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

3 participants