Skip to content

Function with multi-clause style collapses awkwardly with single clause #7718

Description

@chrismccord

Environment

  • Elixir & Erlang/OTP versions (elixir --version): 1.6.0
  • Operating system: OSX 10.13.4

Current behavior

I've found functions with multi-clause style collapses awkwardly when a single clause is used. Given the following code block:

SomeModule.long_function_name_that_approaches_max_columns(argument, acc, fn
  %SomeStruct{key: key}, acc -> more_code(key, acc)
end)

The formatter produces:

SomeModule.long_function_name_that_approaches_max_columns(argument, acc, fn %SomeStruct{
                                                                              key: key
                                                                            },
                                                                            acc ->
  more_code(key, acc)
end)

Expected behavior

The formatter does not change the original code. I realize using the multi-clause style could be "cheating" in this case, but if you add a second clause, the formatter does not change the code, and the formatted code in this case is very awkwardly styled. Thanks for taking a look!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions