fix(css): improve unicode wildcard range recovery#9354
fix(css): improve unicode wildcard range recovery#9354denbezrukov wants to merge 2 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 2825e76 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis PR improves the CSS parser's unicode-range recovery when a wildcard range is followed by a hyphen. It adds a recovery path that emits a Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_css_parser/src/syntax/property/unicode_range.rs (1)
73-75: Use a wider span for this diagnostic.Nice recovery path, but
p.cur_range()here highlights only-. Spanning from the wildcard start through the hyphen would better point at the offending construct.Suggested tweak
- if is_at_unicode_range_wildcard(p) { - parse_unicode_range_wildcard(p).ok(); + if is_at_unicode_range_wildcard(p) { + let wildcard_start = p.cur_range().start(); + parse_unicode_range_wildcard(p).ok(); if p.at(T![-]) { // Wildcards cannot start a range interval (e.g. `U+????-2222`); consume the tail to recover. - let range = p.cur_range(); + let range = TextRange::new(wildcard_start, p.cur_range().end()); p.error(wildcard_range_interval_not_allowed(p, range));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_css_parser/src/syntax/property/unicode_range.rs` around lines 73 - 75, The diagnostic currently uses p.cur_range() which only highlights the hyphen; change it to span from the wildcard start through the hyphen by computing a range that begins at the wildcard token start and ends at the current position (e.g. capture token start before consuming the wildcard or use an available previous/start range API), then pass that wider range into wildcard_range_interval_not_allowed instead of p.cur_range(); keep the subsequent p.bump_with_context(T![-], CssLexContext::UnicodeRange) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/biome_css_parser/src/syntax/property/unicode_range.rs`:
- Around line 73-75: The diagnostic currently uses p.cur_range() which only
highlights the hyphen; change it to span from the wildcard start through the
hyphen by computing a range that begins at the wildcard token start and ends at
the current position (e.g. capture token start before consuming the wildcard or
use an available previous/start range API), then pass that wider range into
wildcard_range_interval_not_allowed instead of p.cur_range(); keep the
subsequent p.bump_with_context(T![-], CssLexContext::UnicodeRange) unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ce0ec6e1-e6b1-4d04-95d2-e0540aab40ac
📒 Files selected for processing (1)
crates/biome_css_parser/src/syntax/property/unicode_range.rs
Summary
Improves CSS unicode-range error recovery for invalid values that mix wildcard ranges with
explicit intervals.
Test Plan
cargo test -p biome_css_parser