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

Slightly better breaking of unary prefix symbols. #2388

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

jordwalke
Copy link
Member

@jordwalke jordwalke commented Apr 17, 2019

Summary:
Before these would break like:

!!
  myFunction(
    foo,
    bar
  )

But now they break like

!!myFunction(
    foo,
    bar
  )

This is still not ideal, but it's an improvement.

Also, one downside is that now closing parens next to unary ! are not aligned to two character grid, though they are still correctly "lined up" with their function call.

let res =
  !myFunction(
     foo,
     bar
   )

However, I think that is better than what was there previously.

let res =
  !
    myFunction(
      foo,
      bar
    )

Unary minus and friends are also improved.

let res =
  -
    myFunction(
      foo,
      bar
    )

Is now:

let res =
  - myFunction(
       foo,
       bar
     )

Unary minus doesn't have any two character grid problems because there is always a space after them. It's mostly about ! and I'd say this is still an improvement.

To fix the remaining issue seems pretty invasive at the moment.

For a future improvement, I might suggest a pass that prepends unary operators to
function names in certain cases, and then running the printer as if these unary
prefixes didn't even exist (in those cases).

Summary:
Before these would break like:

```
!!
  myFunction(
    foo,
    bar
  )

```
But now they break like

```
!!myFunction(
    foo,
    bar
  )

```

This is still not ideal, but it's an improvement.

Also, one downside is that now broken nots are not aligned to two characters.

```
let res =
  !myFunction(
     foo,
     bar
   )

```

However, I think that is better than what was there previously.

```
let res =
  !
    myFunction(
      foo,
      bar
    )

```

This doesn't come up with unary minus, or even unary operators that are of
character length two. It's mostly about `!`. I'd say this is still an
improvement.

To fix the remaining issue seems pretty invasive at the moment.

For a better fix, I might suggest a pass that prepends unary operators to
function names in certain cases, and then running the printer as if these unary
prefixes didn't even exist (in those cases).

Test Plan:

Reviewers:

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

Successfully merging this pull request may close these issues.

None yet

2 participants