Unexpected decoration marks for nested expressions


I implemented a simple grammar for parsing a filter field language. the parser works perfectly fine and gives me the expected tree (tested on https://lezer-playground.vercel.app/, output see screenshot).

what I’m now trying to do is to create decorations, wrapping filter statements like x = y and filter groups like (x = y AND foo = bar).

I created an example with what I currently have here.

it is somehow working, but not always…

the problem:
when I run the example with the pre-defined doc, I get three cm-group spans instead of just one with nested groups.
Screenshot 2023-11-03 at 14.29.20

when I then delete (test = 1 OR test = 2), I’m down to the expected single group with nested statements and one nested group.
Screenshot 2023-11-03 at 14.32.08

pasting the deleted text back in, I end up with two groups
Screenshot 2023-11-03 at 14.35.00

what I would expect is to always have just one wrapping cm-group span.
it would be awesome if you could help figure out why, I have no idea…