fix(issue#4316): color calc inside from expression#4434
fix(issue#4316): color calc inside from expression#4434puckowski wants to merge 2 commits intoless:masterfrom
Conversation
* Fix color calc() inside from expression parsing issues. * Add tests for less#4316.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughA parsing logic fix updates the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment Tip You can customize the tone of the review comments and chat replies.Configure the |
There was a problem hiding this comment.
Pull request overview
Fixes Less parsing for modern color rgb(from …) syntax when calc() expressions include channel identifiers at boundaries (notably right-operands like 100 - r), addressing issue #4316 and preventing erroneous parse failures/operator dropping.
Changes:
- Updated
colorOperandparsing to recognize channel operands (l/c/h/r/g/b/s) when followed by whitespace or common delimiters (e.g.,)). - Added unit fixtures covering
calc(100 - r)andcalc(r + 100)insidergb(from …).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/test-data/tests-unit/color-functions/modern.less | Adds Less inputs reproducing #4316 scenarios for rgb(from … calc(...)). |
| packages/test-data/tests-unit/color-functions/modern.css | Adds expected CSS outputs ensuring operators are preserved and parsing succeeds. |
| packages/less/lib/less/parser/parser.js | Broadens colorOperand matching to allow delimiter lookahead (incl. )), fixing boundary parsing in calc() within from color syntax. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: matthew-dean <414752+matthew-dean@users.noreply.github.com> Agent-Logs-Url: https://github.com/less/less.js/sessions/4d1ac45c-4305-43e1-962f-991415b969e0
Co-authored-by: matthew-dean <414752+matthew-dean@users.noreply.github.com> Agent-Logs-Url: https://github.com/less/less.js/sessions/08abb38c-787e-402a-b782-6b9c55d5f943
|
Some automated Copilot feedback that apparently it couldn't post here, reposting: Review comment — on |
What:
calccalls insidefromexpressions for colors #4316.Validate that:
does not result in
Could not parse call arguments or missing ')'and make sure the following:
has the correct output.
Why:
The above examples should be valid Less but previously causing parsing issues or failed silently.
Checklist:
Summary by CodeRabbit
Tests
rgb(from <color> ... )expressions with arithmetic operations on color channels.Bug Fixes