Files
swift-mirror/test/SourceKit/CodeFormat/rdar_32789463.swift
Nathan Hawes 99edbf0e56 [SourceKit/CodeFormat] Don't column-align PatternBindingDecl entries 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
2020-05-21 11:49:35 -07:00

17 lines
578 B
Swift

struct $ {
let $: <#Type#>
= foo("foo \($) bar") {
$
// RUN: %sourcekitd-test -req=format -line=1 -length=1 %s >%t.response
// RUN: %sourcekitd-test -req=format -line=2 -length=1 %s >>%t.response
// RUN: %sourcekitd-test -req=format -line=3 -length=1 %s >>%t.response
// RUN: %sourcekitd-test -req=format -line=4 -length=1 %s >>%t.response
// RUN: %FileCheck --strict-whitespace %s <%t.response
// CHECK: key.sourcetext: "struct $ {"
// CHECK: key.sourcetext: " let $: <#Type#>"
// CHECK: key.sourcetext: " = foo(\"foo \\($) bar\") {"
// CHECK: key.sourcetext: " $"