Hi,
I changed lines 695 in bin/context/tex/texmf-context/tex/context/base/strc-reg.lua to the above. I re-ran context against my test case and Philipp's example.
Actual results:
a
foo 2
aa 2
aaa 2
aaaa
bar 2
aaaaa
foo 2
aaaaaa 2
Expected results:
a
foo 2
aa
foo 2
aaa
foo 2
aaaa
bar 2
aaaaa
foo 2
aaaaaa 2
Kindest regards.