diff --git a/packages/tailwindcss-language-service/src/util/getLanguageBoundaries.ts b/packages/tailwindcss-language-service/src/util/getLanguageBoundaries.ts index 7630b652..a4817e3a 100644 --- a/packages/tailwindcss-language-service/src/util/getLanguageBoundaries.ts +++ b/packages/tailwindcss-language-service/src/util/getLanguageBoundaries.ts @@ -10,7 +10,7 @@ import { getTextWithoutComments } from './doc' import { isCssLanguage } from './css' export type LanguageBoundary = { - type: 'html' | 'js' | 'css' | (string & {}); + type: 'html' | 'js' | 'jsx' | 'css' | (string & {}); range: Range lang?: string } @@ -24,6 +24,11 @@ let htmlScriptTypes = [ 'text/x-handlebars-template', ] +let jsxScriptTypes = [ + // https://github.com/tailwindlabs/tailwindcss-intellisense/issues/906 + 'text/babel', +] + let text = { text: { match: /[^]/, lineBreaks: true } } let states = { @@ -190,6 +195,8 @@ export function getLanguageBoundaries( boundaries[boundaries.length - 1].type = token.text } else if (token.type === 'type' && htmlScriptTypes.includes(token.text)) { boundaries[boundaries.length - 1].type = 'html' + } else if (token.type === 'type' && jsxScriptTypes.includes(token.text)) { + boundaries[boundaries.length - 1].type = 'jsx' } } offset += token.text.length diff --git a/packages/vscode-tailwindcss/CHANGELOG.md b/packages/vscode-tailwindcss/CHANGELOG.md index cc138c86..8773adba 100644 --- a/packages/vscode-tailwindcss/CHANGELOG.md +++ b/packages/vscode-tailwindcss/CHANGELOG.md @@ -5,6 +5,7 @@ - Fix crash when class regex matches an empty string (#897) - Support Astro's `class:list` attribute by default (#890) - Fix hovers and CSS conflict detection in Vue `