Skip to content

fix: extend colorOperand to cover all relative-color channel letters#4435

Closed
Copilot wants to merge 4 commits intomasterfrom
copilot/improve-documentation-clarity
Closed

fix: extend colorOperand to cover all relative-color channel letters#4435
Copilot wants to merge 4 commits intomasterfrom
copilot/improve-documentation-clarity

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

colorOperand had two bugs corrupting calc() expressions inside relative color syntax (rgb(from …), lab(from …), etc.).

Bug 1 — whitespace consumption dropped operators

/^[lchrgbs]\s+/ consumed the trailing space as part of the match. When a channel keyword appeared as the right-hand operand (e.g. calc(100 - r)), the parser swallowed the - operator silently:

rgb(from blue calc(100 - r) g b)  // emitted: calc(100  r)
rgb(from blue calc(r + 100) g b)  // threw: Could not parse call arguments or missing ')'

Fixed with a lookahead ((?=\s|[,/*)]|$)) and returning the captured letter (match[1]) rather than the full match.

Bug 2 — character class missing a and w

[lchrgbs] only covered RGB / HSL / LCH / OKLCH channels. a (Lab/OKLab) and w (HWB whiteness) were absent, causing identical parse failures:

lab(from blue l calc(a + 5) b)    // threw: Could not parse call arguments
hwb(from blue h calc(w + 10) b)   // threw: Could not parse call arguments

Full single-letter channel set across all CSS relative color functions — r g b (rgb), h s l (hsl), h w b (hwb), l a b (lab/oklab), l c h (lch/oklch) — unique: [abcghlrsw].

Tests

Added regression cases in modern.less / modern.css for both bugs: calc(100 - r), calc(r + 100), calc(a ± n) in lab(), and calc(w ± n) in hwb().

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/
    • Triggering command: /usr/bin/gh gh auth login --with-token --hostname github.com (http block)
  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh auth status (http block)
  • https://api.github.com/repos/less/less.js/pulls/4435
    • Triggering command: /usr/bin/curl curl -s -X PATCH -H Authorization: token ****** -H Accept: application/vnd.github+json REDACTED -d {"state":"closed"} (http block)
    • Triggering command: /usr/bin/curl curl -v -X PATCH -H Authorization: token ****** -H Accept: application/vnd.github+json REDACTED -d {"state":"closed"} (http block)
    • Triggering command: /usr/bin/curl curl -s -H Authorization: ****** -H Accept: application/vnd.github+json REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:


⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI and others added 2 commits March 24, 2026 21:29
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
…(a, w)

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
Copilot AI changed the title [WIP] Improve clarity and consistency in documentation fix: correct colorOperand parser for relative color channel keywords Mar 24, 2026
Copilot AI requested a review from matthew-dean March 24, 2026 21:35
Copilot AI changed the title fix: correct colorOperand parser for relative color channel keywords fix: extend colorOperand to cover all relative-color channel letters Mar 24, 2026
Copilot stopped work on behalf of matthew-dean due to an error March 24, 2026 22:37
Copilot stopped work on behalf of matthew-dean due to an error March 24, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants