diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2017-10-10 12:48:01 +0200 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2017-10-10 14:19:42 +0200 |
commit | 547d042398d1e7191df9f1004c84f880019ea375 (patch) | |
tree | f065d9baa06bee6c7731e9b79d85d9fcfde2c5e1 /lib | |
parent | e519d4346861adcb93179f29c015ffced4d1e25e (diff) | |
download | elixir-547d042398d1e7191df9f1004c84f880019ea375.tar.gz |
Ensure maps/structs with updates converge
Diffstat (limited to 'lib')
-rw-r--r-- | lib/elixir/lib/code/formatter.ex | 2 | ||||
-rw-r--r-- | lib/elixir/test/elixir/code_formatter/containers_test.exs | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/elixir/lib/code/formatter.ex b/lib/elixir/lib/code/formatter.ex index 761df5a9e..39bc37a4e 100644 --- a/lib/elixir/lib/code/formatter.ex +++ b/lib/elixir/lib/code/formatter.ex @@ -1257,7 +1257,7 @@ defmodule Code.Formatter do {right_doc, state} = args_to_algebra_with_comments(right, meta, state, "ed_to_algebra(&1, :parens_arg, &2)) - args_doc = group(glue(left_doc, concat("| ", nest(right_doc, 2)))) + args_doc = glue(left_doc, concat("| ", nest(right_doc, 2))) name_doc = "%" |> concat(name_doc) |> concat("{") {surround(name_doc, args_doc, "}"), state} end diff --git a/lib/elixir/test/elixir/code_formatter/containers_test.exs b/lib/elixir/test/elixir/code_formatter/containers_test.exs index 395451530..d1c651ade 100644 --- a/lib/elixir/test/elixir/code_formatter/containers_test.exs +++ b/lib/elixir/test/elixir/code_formatter/containers_test.exs @@ -529,5 +529,17 @@ defmodule Code.Formatter.ContainersTest do } """ end + + test "converges" do + bad = "hello_world(%struct{foo | 1 => 2, 3 => 4})" + good = """ + hello_world(%struct{ + foo + | 1 => 2, + 3 => 4 + }) + """ + assert_format bad, good, line_length: 30 + end end end |