Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash showing completions in Intellisense when using a custom separator #13306

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Mar 21, 2024

Intellisense uses the internal getVariants API and its use of __TAILWIND_PLACEHOLDER__ crashes inside Tailwind's variant formatting when the separator is _. This crashes the entire completion routine in intellisense and prevents them from appearing.

I've changed it to use no "special" characters to prevent the crash. Instead, we use TAILWINDPLACEHOLDER with a unique, random ID attached to eliminate potential conflicts with registered utilities.

Fixes tailwindlabs/tailwindcss-intellisense#894

@thecrypticace thecrypticace changed the title Fix variant completions in intellisense when using a custom separator Fix crash showing completions in Intellisense when using a custom separator Mar 21, 2024
@@ -1054,7 +1059,7 @@ function registerPlugins(plugins, context) {
values: Object.keys(options.values ?? {}),
hasDash: name !== '@',
selectors({ modifier, value } = {}) {
let candidate = '__TAILWIND_PLACEHOLDER__'
let candidate = `TAILWINDPLACEHOLDER${id}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the placeholder, but I didn't love it before either haha. One potential improvement could be to use a UUID (without the -) but that's almost overkill for this.

crypto.randomUUID().replaceAll('-','')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I really don't like the placeholder either but it's necessary for the current implementation. UUID would definitely be overkill for this.

@thecrypticace thecrypticace merged commit 27e4b65 into master Mar 21, 2024
13 checks passed
@thecrypticace thecrypticace deleted the fix/intellisense-custom-separator branch March 21, 2024 23:38
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.

Config separator not work
2 participants