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 wrapping breaks in weird places #438

Closed
jdavisclark opened this issue Mar 27, 2014 · 4 comments · Fixed by #442
Closed

line wrapping breaks in weird places #438

jdavisclark opened this issue Mar 27, 2014 · 4 comments · Fixed by #442

Comments

@jdavisclark
Copy link

per @jackocnr via jdavisclark/JsFormat#103:


It breaks after negation e.g.

if ( .... lots of conditions here ... && !someVar) {

becomes

if ( .... lots of conditions here ... && !
    someVar) {

and also before property names e.g.

if ( .... lots of conditions here ... && someVar.someProperty) {

becomes

if ( .... lots of conditions here ... && someVar
    .someProperty) {

Both make the code way less readable. Perhaps it should only break on spaces? Or between logical operators e.g. && or ||?

@bitwiseman
Copy link
Member

The negation case is definitely fixable. We can keep the ! with the following word.
The property case basically by design - what if the properties keep going?

if ( .... lots of conditions here ... && someVar.someProperty.someProperty2,.someProperty3.someProperty4) {

When should we give up and choose to break? (#200 limits our knowledge) We choose to wrap.

@bitwiseman
Copy link
Member

Just to be clear, I made a change that should get rid of some cases where ! is left on the previous line. There might be more cases of ! or other unary operators than need addressing. Feel free to file those.

The property stuff is by design.

@clemblanco
Copy link

Can we have if (! something) {?

@bitwiseman
Copy link
Member

@ClayMM - Please file a new issue with input, expected output, and actual output.

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

Successfully merging a pull request may close this issue.

3 participants