Skip to content

Commit

Permalink
fix: don't order sections unless an explicit order is given
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Apr 11, 2024
1 parent 51b9d30 commit e111f1c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/spark/formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,13 @@ defmodule Spark.Formatter do
end)

new_sections =
section_exprs
|> Enum.sort_by(fn {{name, _, _}, _} ->
Enum.find_index(section_names, &(&1 == name))
end)
if config[using][:section_order] && config[using][:section_order] != [] do
Enum.sort_by(section_exprs, fn {{name, _, _}, _} ->
Enum.find_index(section_names, &(&1 == name))
end)
else
section_exprs
end

new_section_indexes =
section_exprs
Expand Down Expand Up @@ -218,6 +221,7 @@ defmodule Spark.Formatter do
end

defp sort_sections(sections, nil), do: sections
defp sort_sections(sections, []), do: sections

defp sort_sections(sections, section_order) do
{ordered, unordered} =
Expand Down

0 comments on commit e111f1c

Please sign in to comment.