Skip to content

Commit 83cccdb

Browse files
author
Kim Hokyeong
authored
adjust HAS_IMPORT regex (#1062)
fix #1060 match RegExp `HAS_IMPORT` with `fileMayBeTailwindRelated()` --- ```js let HAS_IMPORT = /@import\s*('[^']+'|"[^"]+");/ let HAS_IMPORT = /@import\s*['"]/ // from fileMayBeTailwindRelated() ``` It seemed like the regex only accepted `@import '~~~';`, so `@import '~~~' layer(xxx);` did not match. Therefore, I loosened the regex of `HAS_IMPORT` a bit so that it would match the other parts. <sub>translated from japanese</sub>
1 parent 6c3409a commit 83cccdb

File tree

7 files changed

+225
-1
lines changed

7 files changed

+225
-1
lines changed

packages/tailwindcss-language-server/src/project-locator.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,19 @@ testFixture('v4/auto-content', [
152152
},
153153
])
154154

155+
testFixture('v4/auto-content-split', [
156+
//
157+
{
158+
config: 'src/app.css',
159+
content: [
160+
'{URL}/package.json',
161+
'{URL}/src/index.html',
162+
'{URL}/src/components/example.html',
163+
'{URL}/src/**/*.{py,tpl,js,vue,php,mjs,cts,jsx,tsx,rhtml,slim,handlebars,twig,rs,njk,svelte,liquid,pug,md,ts,heex,mts,astro,nunjucks,rb,eex,haml,cjs,html,hbs,jade,aspx,razor,erb,mustache,mdx}',
164+
],
165+
},
166+
])
167+
155168
testFixture('v4/custom-source', [
156169
//
157170
{

packages/tailwindcss-language-server/src/project-locator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ class FileEntry {
661661
isMaybeTailwindRelated(): boolean {
662662
if (!this.content) return false
663663

664-
let HAS_IMPORT = /@import\s*('[^']+'|"[^"]+");/
664+
let HAS_IMPORT = /@import\s*['"]/
665665
let HAS_TAILWIND = /@tailwind\s*[^;]+;/
666666
let HAS_DIRECTIVE = /@(theme|plugin|config|utility|variant|apply)\s*[^;{]+[;{]/
667667

packages/tailwindcss-language-server/tests/fixtures/v4/auto-content-split/package-lock.json

Lines changed: 200 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"tailwindcss": "^4.0.0-alpha.25",
4+
"@tailwindcss/oxide": "^4.0.0-alpha.25"
5+
}
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import "tailwindcss/preflight" layer(base);
2+
@import "tailwindcss/theme" layer(theme);
3+
@import "tailwindcss/utilities" layer(utilities);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div class="underline">Test</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div class="flex">Test</div>

0 commit comments

Comments
 (0)