Okay, I am unable to test this at the moment, but: In the expression
{$foo} doesn't TextMate take the } as the closing brace for $? That
would mean that there is still one unmatched opening brace {.
I see what you mean. Yes, that is a problem: see below for a fix.
The reason you confused me is that this doesn't affect "Select
Enclosing Brackets", which I don't think uses the scope information
at all. Indeed, "Select Enclosing Brackets" works perfectly as expected
in all the cases I've tested, including the one you just posted.
You *can* see the problem by typing
{$foo}
positioning the cursor after it, and pressing control-shift-P. This shows that
the brace group is still in effect. The fix is to use a lookahead:
…
{ name = 'string.other.math.tex';
begin = '\$';
end = '(?=\})|\$';
…
Thanks for pointing this out.
Robin