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

[SR-15167] Weird newline with optional chaining #305

Open
karwa opened this issue Sep 7, 2021 · 2 comments
Open

[SR-15167] Weird newline with optional chaining #305

karwa opened this issue Sep 7, 2021 · 2 comments
Labels
bug Something isn't working swift-format

Comments

@karwa
Copy link
Contributor

karwa commented Sep 7, 2021

Previous ID SR-15167
Radar None
Original Reporter @karwa
Type Bug
Environment

swift-format 0.50300.0

Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels Bug
Assignee None
Priority Medium

md5: 2f04a8858227c6ebd6c94f80e9e6a07e

Issue Description:

Given this input:

func test() {
  let result = newValue.withContiguousStorageIfAvailable {
    setNewValue($0)
  } ?? setNewValue(newValue)
}

For some reason, swift-format decides it would be better with a newline and if everything was indented:

func test() {
  let result =
    newValue.withContiguousStorageIfAvailable {
      setNewValue($0)
    } ?? setNewValue(newValue)
}

But I think this looks quite a lot worse. The actual body, involving wCSIA and the optional chaining, seems to be kept intact... it's just a bit lower and to the side. I'm not sure how that helps anything.

I'm not sure which rule is causing this or how to disable it, but I'd really like if swift-format could stop doing it. It's not a line-length issue: my max length is set at 120 and the original doesn't get anywhere near that.

@typesanitizer
Copy link

cc @allevato

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
@ahoppen
Copy link
Contributor

ahoppen commented Apr 23, 2024

Tracked in Apple’s issue tracker as rdar://126948211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working swift-format
Projects
None yet
Development

No branches or pull requests

3 participants