Open mnazirov opened 1 year ago
@mnazirov that's a super-old version. Can you check that it's still happening on 0.51.15 before I investigate further? Thanks.
@nicklockwood Updated to version 0.51.15, but the issue with line breaks in generic types still persists Before formatting
func createConnectScreen() -> DestinationStep<NewConnectFactory.ViewController, NewConnectFactory.Context> {
...
}
After formatting
func createConnectScreen() -> DestinationStep<
NewConnectFactory.ViewController,
NewConnectFactory.Context
> {
...
}
@mnazirov thanks for double checking. The issue is that --nowrapoperators
only applies to operators, and <
isn't considered an operator by SwiftFormat when it's used as a bracket in a generics list.
It's not especially difficult for me to change that behavior, but I'm not sure if that would really solve your problem in this case, as it would just wrap at the ,
instead, which presumably isn't what you'd want.
What is the behavior you'd want in this case? Where should that line wrap?
@nicklockwood Thank you for the detailed explanation. I've tried to ensure only the method parameters wrap, while the return types of generics remain unchanged.
@mnazirov sure, I understand that. But in the example above there are no method parameters, so is your desired behavior that the line should just not wrap at all, even if it exceeds your specified max line width?
@nicklockwood Yep, I want the line breaks to only occur at method arguments. Can you please advise how I can achieve this result?)
Before formatting
func createConnectScreen(argument: Int, argument2: Int) -> DestinationStep<NewConnectFactory.ViewController, NewConnectFactory.Context> {
...
}
Expected formatting result
func createConnectScreen(
argument: Int,
argument2: Int
) -> DestinationStep<NewConnectFactory.ViewController, NewConnectFactory.Context> {
...
}
@nicklockwood I think there's no way to do this currently other than to disable the wrap
rule.
Thank you so much for the speedy reply)
Hello @nicklockwood , I have the following case where 0.48.11 SwiftFormat line breaks at generic types. Adding in the symbol exception didn't help Before formatting
After formatting
Before formatting
After formatting
Configurations