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

Improve binary expressions hanging #163

Merged
merged 14 commits into from
May 20, 2021
Merged

Improve binary expressions hanging #163

merged 14 commits into from
May 20, 2021

Conversation

JohnnyMorganz
Copy link
Owner

@JohnnyMorganz JohnnyMorganz commented May 19, 2021

This PR improves formatting of hanging binary expressions:

Binary expressions are stored in the AST in a tree-like representation. Originally, we would always hang on the root node of this tree, even if doesn't necessarily need to happen (e.g. if we have already hung the LHS of this root node, and now the binop and RHS are under the column width).
This PR now takes the amount of space left on the line into account before hanging at the root node. This means we will no longer unnecessarily hang across multiple lines, which should make code less verbose and cleaner.

Also fixes #154 - leading comments to a binop are preserved, and leading comments of the RHS expression of a binop are moved to before the binop

@JohnnyMorganz JohnnyMorganz changed the title Improve hanging Improve binary expressions hanging May 19, 2021
@JohnnyMorganz JohnnyMorganz marked this pull request as ready for review May 19, 2021 23:01
It seemed to be previously wrong
@JohnnyMorganz JohnnyMorganz merged commit a4c0a1b into master May 20, 2021
@JohnnyMorganz JohnnyMorganz deleted the improve-hanging branch May 20, 2021 18:45
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 this pull request may close these issues.

Mistransformation when formatting a comment within a string concatenation chain Hang on equality operators
1 participant