You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: stop highlighting leaks, fix the Enter command and snippet, and add modern color swatches - #465
This PR fixes the highlighting, Enter-key, snippet, and color-swatch bugs from the open issue triage, and adds what styled-components v7 users need: swatches for wide-gamut colors and highlighting for modern CSS functions.
What changes for you
Highlighting stays inside the template. CSS highlighting no longer spills into the code after a template's closing backtick (#383, #292, #358, #442, #196).
More ways of writing styled components highlight. Examples:
Prettier-split tag chains (styled.div or Button.extend, then any number of .attrs() and .withConfig() calls)
A comment between styled.div and its backtick
Tags reached through an object, a call, or an index (theme.styled.div, $styled.div, getTheme().styled.div)
Type arguments that span several lines
Arrow functions like styled.div(($props) => ...) and styled.div(p => ...)
Modern CSS highlights. Functions such as oklch(), color-mix(), clamp(), and light-dark() highlight as functions. Keyframe selectors with decimals, like 33.3%, highlight as one selector inside an @keyframes block.
Highlighting is faster. Highlighting is about 8% faster on average. This was measured over about 5,800 lines of styled-components code in JavaScript and TSX, both on the first highlight of a file and after. Very long single lines gained the most, about 65% faster on average.
The Enter key works after a nested template. Pressing Enter on a suggested property inserts : ; even when the template holds another template, like ${css...} (#437).
The backtick snippet appears only where it belongs. "expand template string" is offered only right after a backtick that opens a styled template (#386).
Color swatches cover modern formats. These now show swatches and open the color picker:
The picker writes the same values VS Code writes in .css files. A semi-transparent hex color always gets a valid two-digit alpha.
VS Code 1.74 or later is required. VS Code then starts the extension for the Enter command in any JavaScript or TypeScript file, not only after a JSX or TSX file opens. Anyone on an older VS Code keeps the version they have.
For contributors
docs/spec.md is the behavior spec. It covers recognized tags, the Enter command, the snippet, color formats, performance budgets, and the public contract. A behavior change edits it first.
The grammars are generated from TypeScript in syntaxes/src/. VS Code's CSS grammar is vendored and its rules are copied in, so highlighting is the same whichever VS Code version you run.
Every highlighting fixture ends with const sentinel = 1;. A leak changes that line's scopes, and the test fails.
npm run test:unit, npm run tokenize, and npm run bench:grammar run without opening a VS Code window.
ThirdPartyNotices.txt now also credits atom/language-sass, the source of the grammar's SCSS-derived rules.
Commit messages and PR titles follow Conventional Commits, checked by a commit-msg hook and a CI job.
Public contract
This is a minor release; nothing a theme or another extension relies on changes. The spec now lists, as stable, the extension id, the grammar scopes, the command id, and the extension's own CSS scope names (the .scss names that VS Code's default themes color). Names that come from VS Code's own grammars follow those grammars.
Node runs the .mts build and test scripts directly (Node 22.18 or later), and tsc typechecks every TypeScript file. The integration suites are bundled with esbuild before the test run, and unit tests run in Node without a VS Code window. glob and d3-color are no longer dependencies.
A commit-msg hook and a "Commit messages" CI job check each message and the PR title. The release PR and Dependabot PRs use conventional titles, and CI runs the unit tests and typecheck in the Lint job.
The tokenizer prints tokens with the pinned VS Code's grammars without opening a window, checks sentinel lines, and compares fixtures with their committed results. The benchmark compares grammar speed against other grammar folders. Every fixture ends with a sentinel line that fails the colorization suite when highlighting leaks.
…eaks, and highlight modern CSS
The grammars are generated from TypeScript sources, with VS Code's CSS grammar vendored and its rules copied in. Highlighting no longer spills past a template's closing backtick, more tag shapes are recognized, modern CSS functions highlight as functions, and CSS tokenizes faster.
Fixes#383, #292, #358, #442, #196
…hat agrees with the grammar
The Enter command and the backtick snippet share one scanner over the text before the cursor. It handles nested templates and matches the grammar's tag shapes, a differential test checks it against every colorize result, and the snippet is offered only after a backtick that opens a styled template.
Fixes#437, #386
Space-separated rgb() and hsl(), hwb(), lab(), lch(), oklab(), and oklch() get swatches, hex alpha pads correctly, and the color picker writes readable hsl.
Fixes#455
quantizor
changed the title
Behavior spec, leak-catching tests, and fixes for highlighting, Enter, snippet, and colors
feat: stop highlighting leaks, fix the Enter command and snippet, and add modern color swatches
Nov 19, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The integration suite stalls on an unsaved-fixture dialog, and escaped backticks inside existing styled templates incorrectly trigger the expansion completion.
This PR improves styled-components editing in VS Code by addressing highlighting leaks, correcting Enter-key and snippet behavior, and adding modern CSS color support. It also expands regression coverage and updates contributor tooling.
Changes:
Broaden styled-template recognition and add fixtures that detect highlighting leaking into surrounding code.
Fix nested-template Enter handling, restrict backtick expansion, and support modern color swatches and picker output.
Introduce TypeScript-based grammar and test tooling, strengthen CI checks, and document release changes.
File
Description
tsconfig.json
Extends strict typechecking to tooling and tests.
ThirdPartyNotices.txt
Adds notices for inherited CSS and SCSS grammar rules.
syntaxes/src/grammarTypes.ts
Defines shared grammar types.
syntaxes/src/generate.mts
Generates the packaged grammar JSON files.
src/tests/vscodeVersion.mts
Centralizes the existing VS Code test pin.
src/tests/suite/index.ts
Adds the TypeScript integration-suite loader.
src/tests/suite/index.js
Removes the old JavaScript suite loader.
src/tests/suite/extension.test.ts
Converts test imports to TypeScript module syntax.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Accepting a CSS property or function completion discards secondary cursors because the command assigns a single editor.selection instead of preserving all selections.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve secondary cursors when accepting completions
src/insertColonCommand.ts:55
Assigning editor.selection replaces all selections with the primary one, so accepting a CSS property with multiple cursors now discards every secondary cursor. The function-completion branch at lines 60–61 has the same regression. Use editor.selections to retain all cursors and coordinate their positions with the edits instead of assigning a single selection.
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
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.
This PR fixes the highlighting, Enter-key, snippet, and color-swatch bugs from the open issue triage, and adds what styled-components v7 users need: swatches for wide-gamut colors and highlighting for modern CSS functions.
What changes for you
Highlighting stays inside the template. CSS highlighting no longer spills into the code after a template's closing backtick (#383, #292, #358, #442, #196).
More ways of writing styled components highlight. Examples:
styled.divorButton.extend, then any number of.attrs()and.withConfig()calls)styled.divand its backticktheme.styled.div,$styled.div,getTheme().styled.div)styled.div(($props) => ...)andstyled.div(p => ...)Modern CSS highlights. Functions such as
oklch(),color-mix(),clamp(), andlight-dark()highlight as functions. Keyframe selectors with decimals, like33.3%, highlight as one selector inside an@keyframesblock.Highlighting is faster. Highlighting is about 8% faster on average. This was measured over about 5,800 lines of styled-components code in JavaScript and TSX, both on the first highlight of a file and after. Very long single lines gained the most, about 65% faster on average.
The Enter key works after a nested template. Pressing Enter on a suggested property inserts
: ;even when the template holds another template, like${css...}(#437).The backtick snippet appears only where it belongs. "expand template string" is offered only right after a backtick that opens a styled template (#386).
Color swatches cover modern formats. These now show swatches and open the color picker:
rgb()andhsl(), with or without/ alpha(Color preview and color picker do not work without commas in HSL #455)hwb(),lab(),lch(),oklab(), andoklch()The picker writes the same values VS Code writes in
.cssfiles. A semi-transparent hex color always gets a valid two-digit alpha.VS Code 1.74 or later is required. VS Code then starts the extension for the Enter command in any JavaScript or TypeScript file, not only after a JSX or TSX file opens. Anyone on an older VS Code keeps the version they have.
For contributors
docs/spec.mdis the behavior spec. It covers recognized tags, the Enter command, the snippet, color formats, performance budgets, and the public contract. A behavior change edits it first.syntaxes/src/. VS Code's CSS grammar is vendored and its rules are copied in, so highlighting is the same whichever VS Code version you run.const sentinel = 1;. A leak changes that line's scopes, and the test fails.npm run test:unit,npm run tokenize, andnpm run bench:grammarrun without opening a VS Code window.ThirdPartyNotices.txtnow also credits atom/language-sass, the source of the grammar's SCSS-derived rules.Public contract
This is a minor release; nothing a theme or another extension relies on changes. The spec now lists, as stable, the extension id, the grammar scopes, the command id, and the extension's own CSS scope names (the
.scssnames that VS Code's default themes color). Names that come from VS Code's own grammars follow those grammars.