Is it intentional that the sections aren’t nested for the purposes of the operation?
For example:
# sec1
## subsec1
cat
## subsec2
dog
section:(cat dog) won’t match that one.
Came up today because I was actually trying section:(/foobar/ -"## Key") which should have found all foobar in the file except for the ones in the top Key section.
However, since that section was split into ### Sub1 ### Sub2 etc, I couldn’t exclude the whole key that way. Instead I had to do section(/foobar/ -"### Sub1" -"### Sub2"). As it happens, that worked in that file, but only because Sub1/Sub2 were unique to the key. Otherwise I’d have to flatten out the Key section to use bold plaintext instead of true subheaders.
I could see the intention going either way, and the heading to heading search with no nest awareness is definitely easier technically. However, transclusion works nested, and I’d probably expect this to work like transclusion and other header-aware functionality, where a line is part of multiple sections at once.