Skip to content

fix: insert child right after the last after: match in add_new_child/3 - #407

Merged
zachdaniel merged 1 commit into
ash-project:mainfrom
pshoukry:fix-add-new-child-after
Oct 2, 2026
Merged

zachdaniel merged 1 commit into
ash-project:mainfrom
pshoukry:fix-add-new-child-after

Conversation

@pshoukry

@pshoukry pshoukry commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

add_new_child/3 with after: inserted the child one place too late whenever a non-matching child followed the last match. Closes #406.

skip_after/2 walked right past the last match and, on reaching a non-matching child, returned {:after, that_child} because of a nested? flag. The flag is gone: a non-matching child now returns {:before, child}, which is the slot right after the last match.

# children = [Test.Repo, TestWeb.Endpoint]
add_new_child(igniter, NewChild, after: [Test.Repo])
# before => [Test.Repo, TestWeb.Endpoint, NewChild]
# after  => [Test.Repo, NewChild, TestWeb.Endpoint]

Real change: lib/igniter/project/application.ex (+2/-6).

Tests (test/igniter/project/application_test.exs, 5 new):

Case Without fix
match followed by a non-matching child fails
several matches, then a non-matching child fails
non-matching child between matches fails
match is the last child passes (control)
no match, child goes first passes (control)

Full suite: 444 tests, 1 doctest, 0 failures. mix format --check-formatted, mix credo --strict and mix dialyzer are clean.

I did not touch CHANGELOG.md; the release task generates it from commit messages.

@zachdaniel

Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

@zachdaniel
zachdaniel merged commit f638ce7 into ash-project:main Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add_new_child/3 with after: inserts one child too late

2 participants