Skip to content

Commit 034c2d2

Browse files
committed
Don’t start language server for preprocessor files with @import
1 parent a533fbf commit 034c2d2

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

packages/vscode-tailwindcss/src/analyze.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,19 @@ export async function fileMayBeTailwindRelated(uri: Uri) {
108108
let buffer = await workspace.fs.readFile(uri)
109109
let contents = buffer.toString()
110110

111-
return (
112-
HAS_CONFIG.test(contents) ||
113-
HAS_IMPORT.test(contents) ||
114-
HAS_TAILWIND.test(contents) ||
115-
HAS_THEME.test(contents)
116-
)
111+
// This is a clear signal that this is Tailwind related in v0–v4
112+
if (HAS_CONFIG.test(contents)) return true
113+
114+
if (uri.path.endsWith('.css')) {
115+
// In v4 these are Tailwind related *in .css files only*
116+
// other stylesheets like lesss, stylus, etc… don't consider these files
117+
if (HAS_THEME.test(contents)) return true
118+
if (HAS_TAILWIND.test(contents)) return true
119+
120+
// @import *might* signal the need for the language server we'll have to
121+
// start it, let it check, and hope we were right.
122+
if (HAS_IMPORT.test(contents)) return true
123+
}
124+
125+
return false
117126
}

0 commit comments

Comments
 (0)