Skip to content

Commit 27e4b65

Browse files
Fix crash showing completions in Intellisense when using a custom separator (#13306)
* Fix variant completions in intellisense when using a custom separator * Update changelog
1 parent 9b90c53 commit 27e4b65

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Sort arbitrary properties alphabetically across multiple class lists ([#12911](https://github.com/tailwindlabs/tailwindcss/pull/12911))
1616
- Add `mix-blend-plus-darker` utility ([#12923](https://github.com/tailwindlabs/tailwindcss/pull/12923))
1717
- Ensure dashes are allowed in variant modifiers ([#13303](https://github.com/tailwindlabs/tailwindcss/pull/13303))
18+
- Fix crash showing completions in Intellisense when using a custom separator ([#13306](https://github.com/tailwindlabs/tailwindcss/pull/13306))
1819

1920
## [3.4.1] - 2024-01-05
2021

src/lib/setupContextUtils.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,11 @@ function registerPlugins(plugins, context) {
10441044

10451045
// Generate a list of available variants with meta information of the type of variant.
10461046
context.getVariants = function getVariants() {
1047+
// We use a unique, random ID for candidate names to avoid conflicts
1048+
// We can't use characters like `_`, `:`, `@` or `.` because they might
1049+
// be used as a separator
1050+
let id = Math.random().toString(36).substring(7).toUpperCase()
1051+
10471052
let result = []
10481053
for (let [name, options] of context.variantOptions.entries()) {
10491054
if (options.variantInfo === VARIANT_INFO.Base) continue
@@ -1054,7 +1059,7 @@ function registerPlugins(plugins, context) {
10541059
values: Object.keys(options.values ?? {}),
10551060
hasDash: name !== '@',
10561061
selectors({ modifier, value } = {}) {
1057-
let candidate = '__TAILWIND_PLACEHOLDER__'
1062+
let candidate = `TAILWINDPLACEHOLDER${id}`
10581063

10591064
let rule = postcss.rule({ selector: `.${candidate}` })
10601065
let container = postcss.root({ nodes: [rule.clone()] })

0 commit comments

Comments
 (0)