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

Improved object-break heuristic #5205

Merged
merged 4 commits into from Oct 12, 2018

Conversation

Projects
None yet
5 participants
@j-f1
Member

j-f1 commented Oct 8, 2018

This changes the heuristic from breaking the object if it contains a newline somewhere inside it to only breaking if the newline is between the { and the first key. This allows users to easily collapse objects by deleting that linebreak without having to manually move the object onto one line.

@j-f1 j-f1 added the status:wip label Oct 8, 2018

@j-f1

This comment has been minimized.

Member

j-f1 commented Oct 8, 2018

Ref #5170.

@j-f1 j-f1 removed the status:wip label Oct 8, 2018

@lydell

This comment has been minimized.

Collaborator

lydell commented Oct 8, 2018

I kind of like the shortcut aspect of it, but I'm afraid this will be harder to explain/teach.

I think it's pretty easy to select the object and press the "join lines" keyboard shortcut most editors have (such as ctrl+j, or J in Vim).

@j-f1 j-f1 requested review from ikatyang and vjeux Oct 10, 2018

@vjeux

This comment has been minimized.

Collaborator

vjeux commented Oct 10, 2018

This is an interesting concept. I also hate having to remove every single new line in order to get it back into a single line. @lydell I had no idea that ctrl-J was a thing, and I've never seen people actually use that in practice, so I wouldn't count people knowing about it.

I'd happy happy to try this out, it seems like it wouldn't change any existing formatting so should be a strictly better user experience.

@suchipi

This comment has been minimized.

Member

suchipi commented Oct 11, 2018

I'm in favor of this change, better DX for sure 👍

@j-f1 j-f1 merged commit 65b2454 into prettier:master Oct 12, 2018

10 checks passed

ci/circleci: build_prod Your tests passed on CircleCI!
Details
ci/circleci: checkout_code Your tests passed on CircleCI!
Details
ci/circleci: test_prod_node4 Your tests passed on CircleCI!
Details
ci/circleci: test_prod_node9 Your tests passed on CircleCI!
Details
ci/circleci: test_prod_standalone Your tests passed on CircleCI!
Details
codecov/patch 100% of diff hit (target 80%)
Details
codecov/project 96.2% (+<.01%) compared to 303f344
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details

@j-f1 j-f1 deleted the j-f1:alt-object-break-rule branch Oct 12, 2018

@ikatyang ikatyang added this to the 1.15 milestone Oct 25, 2018

@j-f1 j-f1 referenced this pull request Oct 26, 2018

Open

Prettier 2.0 #3503

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