Skip to content

Commit

Permalink
pipes: recursively fix pipe starts (closes #94)
Browse files Browse the repository at this point in the history
  • Loading branch information
novaugust committed Dec 5, 2023
1 parent 1f4e8bb commit a3ff998
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Improvements

* alias: delete noop single-module aliases (`alias Foo`, #87, h/t @mgieger)
* pipes: recursively fix pipe starts (`f(g(h(x))) |> j()` => `x |> h() |> g() |> f() |> j()`, #94, h/t @tomjschuster)

## v0.10.3

Expand Down
2 changes: 1 addition & 1 deletion lib/style/pipes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ defmodule Styler.Style.Pipes do
|> Zipper.insert_left(new_assignment)
|> Zipper.left()
else
{pipe, zmeta}
fix_pipe_start({pipe, zmeta})
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions test/style/pipes_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ defmodule Styler.Style.PipesTest do
use Styler.StyleCase, async: true

describe "big picture" do
test "unnests multiple steps" do
assert_style("f(g(h(x))) |> j()", "x |> h() |> g() |> f() |> j()")
end

test "doesn't modify valid pipe" do
assert_style("""
a()
Expand Down

0 comments on commit a3ff998

Please sign in to comment.