You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder if that's my config file or it's a default behaviour that can't be changed but it seems quite weird to me. When using if conditional blocks as expressions (introduced in Swift 5.9) and assigning them to the properties I'd like to keep them in the same line as the property. When running swift-format the whole expression is moved to the next line.
original:
letqueryParams= if queryParams.isEmpty {""}else{"?"+ queryParams.encodedQueryParams
}
after formatting:
letqueryParams=
if queryParams.isEmpty {""}else{"?"+ queryParams.encodedQueryParams
}
How can I prevent from adding line break in this case?
The text was updated successfully, but these errors were encountered:
mcichecki
changed the title
swift-format breaks line when assigning if as expression to the variable
if expression is moved to the next line when assigned to the property
Oct 5, 2024
This is by design; in most cases where a complex expression follows an assignment, we move the expression to the next line and indent it. There are a limited number of cases where we don't do this, like function calls. However, my gut feeling is to not add more cases like that and we're better off using something like the rectangle rule to guide our line breaking and indentation philosophy here (which is what we do for cases not covered by those exceptions).
I wonder if that's my config file or it's a default behaviour that can't be changed but it seems quite weird to me. When using if conditional blocks as expressions (introduced in Swift 5.9) and assigning them to the properties I'd like to keep them in the same line as the property. When running swift-format the whole expression is moved to the next line.
original:
after formatting:
Config:
How can I prevent from adding line break in this case?
The text was updated successfully, but these errors were encountered: