Repository navigation
Conversation
At-rules ending in a semicolon, such as `@charset`, `@layer x;`, `@namespace` or Tailwind's `@apply`, `@plugin` and `@source`, were left unhighlighted: only `@import` and at-rules followed by a block were. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without a bound, input with many at-rules and no semicolon made every `@` scan to the end of the input, so matching grew quadratically. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At-rules ending in a semicolon were left unhighlighted; only
@importand at-rules followed by a block were:The new
CssAtRulePatternhighlights any@namein statement position whose statement ends in;, rather than a fixed list of names. This covers standard CSS (@charset,@layer,@namespace) and tooling such as Tailwind (@apply,@plugin,@source,@custom-variant…) without listing them.Left untouched on purpose:
@import, which keeps its own pattern.@layer x {,@font-face {), highlighted as before.@inside a value or a string (url("a@b.c"),"@tailwindcss/typography"), and Tailwind variants such as@md:px-6inside@apply.The lookahead for the closing
;is capped at 1000 characters, so input with many@wordand no;stays linear (50,000 of them match in ~30 ms; uncapped it took ~2 s).Added pattern tests, a language test, and tests that long unterminated input matches without a PCRE error.
composer bench: css 189 µs → 190 µs, scss 266 µs → 273 µs (it now highlights@use/@include), other languages unchanged.These changes were made with AI assistance, based on changes already in use in another project, and have been reviewed manually. That project highlights a fixed list of at-rule names; here it is generalised to any statement at-rule.