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

[SourceKit/CodeFormat] Don't column-align PatternBindingDecl entries in certain cases. #31941

Merged
merged 1 commit into from
May 22, 2020

Conversation

nathawes
Copy link
Collaborator

@nathawes nathawes commented May 21, 2020

Don't column align PBD entries if any entry spans from the same line as the var/let to another line. For example:

// Previous behavior:
let foo = someItem
      .getValue(), // Column-alignment (relative to `foo`) looks ok here...
    bar = otherItem
      .getValue()

getAThing()
  .andDoStuffWithIt()
let foo = someItem
      .getValue() // but looks over-indented here, which is far more common.
getOtherThing()
  .andDoStuffWithIt()

// New behavior:
getAThing()
  .andDoStuffWithIt()
let foo = someItem
  .getValue() // No column alignment in this case (good)...
doOtherThing()

let foo = someItem
  .getValue(), // or in this case (unfortunate, but less common)...
  bar = otherItem
    .getValue()

let foo = someItem.getValue(),
    bar = otherItem.getValue() // but still column-aligned in this case (good).

Using this rule, as opposed to handling single and multi-entry PBDs differently, ensures that the as-typed-out indentation matches the selected-and-reindented indentation for multi-entry PBDs.

Resolves rdar://problem/63309288

…in certain cases.

Don't column align PBD entries if any entry spans from the same line as
the var/let to another line. E.g.

```
// Previous behavior:
let foo = someItem
      .getValue(), // Column-alignment looks ok here, but...
    bar = otherItem
      .getValue()

getAThing()
  .andDoStuffWithIt()
let foo = someItem
      .getValue() // looks over-indented here, which is more common.
getOtherThing()
  .andDoStuffWithIt()

// New behavior
getAThing()
  .andDoStuffWithIt()
let foo = someItem
  .getValue() // No column alignment in this case...
doOtherThing()

let foo = someItem
   .getValue(), // Or in this case (unfortunate, but less common)...
   bar = otherItem
       .getValue()

let foo = someItem.getValue(),
    bar = otherItem.getValue() // but still column-aligned in this case.
```

Resolves rdar://problem/63309288
@nathawes nathawes requested a review from benlangmuir May 21, 2020 19:05
@nathawes
Copy link
Collaborator Author

@swift-ci please test

@swift-ci
Copy link
Collaborator

Build failed
Swift Test OS X Platform
Git Sha - 99edbf0

@swift-ci
Copy link
Collaborator

Build failed
Swift Test Linux Platform
Git Sha - 99edbf0

@nathawes
Copy link
Collaborator Author

@swift-ci please test

@nathawes nathawes merged commit defac25 into apple:master May 22, 2020
@nathawes nathawes deleted the pattern-binding-decl-indentation branch May 22, 2020 00:58
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.

None yet

3 participants