Adds a TextMate grammar for ICU expressions (plural and select) so that their braces are no longer mistaken for interpolations.
Previously, a case body that starts with an interpolation, such as one {{{count}} item}, was highlighted incorrectly: the interpolation grammar matched the first two braces of {{{, which left the third one unbalanced inside of the expression and broke bracket matching.
The case value is matched together with the opening brace of the case, which allows the case to start before the interpolation injection gets a chance to match.
Fixes #62697
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
- Bugfix
- Feature
- Code style update (formatting, local variables)
- Refactoring (no functional changes, no api changes)
- Build related changes
- CI related changes
- Documentation content changes
- angular.dev application / infrastructure changes
- Other... Please describe:
What is the current behavior?
ICU expressions have no grammar of their own, so their braces are only ever seen by the interpolation grammar. When a case body starts with an interpolation, the interpolation matches the first two braces of {{{ and the third one ends up unbalanced inside of the expression:
{count, plural,
one {{{count}} Stored Bundle}
other {{{count}} Stored Bundles}
}
This is the ICU counterpart of the block issue fixed in #64392, which noted that ICUs had no named scopes to exclude.
Issue Number: #62697
What is the new behavior?
A new template.icu.ng grammar recognizes plural and select ICU expressions, including nested ones, and highlights the switch expression, the ICU type and the case values.
The case value is matched together with the opening brace of the case. This makes the case start before the interpolation injection gets a chance to match, so the braces of one {{{count}} item} are now tokenized as the case brace followed by an interpolation.
I did not reuse the approach from #64392 (excluding the interpolation injection from the new scope) because the exclusion applies to the whole scope stack: it would also disable interpolation highlighting in attributes of elements inside a case body, e.g. other {<b title="{{ t }}">items</b>}.
Does this PR introduce a breaking change?