Skip to content

Commit 765ebce

Browse files
Fix content detection in later Oxide versions (#1280)
This should improve project selection for files in a workspace with multiple projects. Though probably only a tiny bit.
1 parent 405733b commit 765ebce

File tree

5 files changed

+77
-76
lines changed

5 files changed

+77
-76
lines changed

packages/tailwindcss-language-server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@tailwindcss/forms": "0.5.3",
4141
"@tailwindcss/language-service": "workspace:*",
4242
"@tailwindcss/line-clamp": "0.4.2",
43-
"@tailwindcss/oxide": "^4.0.0-alpha.19",
43+
"@tailwindcss/oxide": "^4.0.15",
4444
"@tailwindcss/typography": "0.5.7",
4545
"@types/braces": "3.0.1",
4646
"@types/color-name": "^1.1.3",

packages/tailwindcss-language-server/src/oxide.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function loadOxideAtPath(id: string): Promise<Oxide | null> {
6868
let oxide = await import(id)
6969

7070
// This is a much older, unsupported version of Oxide before v4.0.0-alpha.1
71-
if (!oxide.scanDir) return null
71+
if (!oxide.scanDir && !oxide.Scanner) return null
7272

7373
return oxide
7474
}
@@ -101,7 +101,7 @@ interface ScanResult {
101101
* For example, the `sources` option is ignored before v4.0.0-alpha.19.
102102
*/
103103
export async function scan(options: ScanOptions): Promise<ScanResult | null> {
104-
const oxide = await loadOxideAtPath(options.oxidePath)
104+
let oxide = await loadOxideAtPath(options.oxidePath)
105105
if (!oxide) return null
106106

107107
// V1

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

+18-27
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { css, defineTest, js, json, scss, Storage, TestUtils } from './testing'
99
let settings: Settings = {
1010
tailwindCSS: {
1111
files: {
12-
exclude: [],
12+
exclude: ['**/.git/**', '**/node_modules/**', '**/.hg/**', '**/.svn/**'],
1313
},
1414
},
1515
} as any
@@ -114,10 +114,7 @@ testFixture('v4/workspaces', [
114114
{
115115
config: 'packages/admin/app.css',
116116
selectors: [
117-
'{URL}/node_modules/tailwindcss/**',
118-
'{URL}/node_modules/tailwindcss/index.css',
119-
'{URL}/node_modules/tailwindcss/theme.css',
120-
'{URL}/node_modules/tailwindcss/utilities.css',
117+
'{URL}/packages/admin/*',
121118
'{URL}/packages/admin/**',
122119
'{URL}/packages/admin/app.css',
123120
'{URL}/packages/admin/package.json',
@@ -126,15 +123,12 @@ testFixture('v4/workspaces', [
126123
{
127124
config: 'packages/web/app.css',
128125
selectors: [
129-
'{URL}/node_modules/tailwindcss/**',
130-
'{URL}/node_modules/tailwindcss/index.css',
131-
'{URL}/node_modules/tailwindcss/theme.css',
132-
'{URL}/node_modules/tailwindcss/utilities.css',
133126
'{URL}/packages/style-export/**',
134127
'{URL}/packages/style-export/lib.css',
135128
'{URL}/packages/style-export/theme.css',
136129
'{URL}/packages/style-main-field/**',
137130
'{URL}/packages/style-main-field/lib.css',
131+
'{URL}/packages/web/*',
138132
'{URL}/packages/web/**',
139133
'{URL}/packages/web/app.css',
140134
'{URL}/packages/web/package.json',
@@ -147,28 +141,24 @@ testFixture('v4/auto-content', [
147141
{
148142
config: 'src/app.css',
149143
content: [
144+
'{URL}/*',
150145
'{URL}/package.json',
151146
'{URL}/src/index.html',
152147
'{URL}/src/components/example.html',
153-
'{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}',
148+
'{URL}/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
154149
],
155150
},
156151
])
157152

158153
testFixture('v4/auto-content-split', [
159-
//
160-
{
161-
// TODO: This should _probably_ not be present
162-
config: 'node_modules/tailwindcss/index.css',
163-
content: [],
164-
},
165154
{
166155
config: 'src/app.css',
167156
content: [
157+
'{URL}/*',
168158
'{URL}/package.json',
169159
'{URL}/src/index.html',
170160
'{URL}/src/components/example.html',
171-
'{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}',
161+
'{URL}/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
172162
],
173163
},
174164
])
@@ -178,23 +168,23 @@ testFixture('v4/custom-source', [
178168
{
179169
config: 'admin/app.css',
180170
content: [
181-
'{URL}/admin/**/*.{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}',
182-
'{URL}/admin/**/*.bin',
171+
'{URL}/*',
183172
'{URL}/admin/foo.bin',
173+
'{URL}/admin/{**/*.bin,**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}}',
184174
'{URL}/package.json',
185175
'{URL}/shared.html',
186-
'{URL}/web/**/*.{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}',
176+
'{URL}/web/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
187177
],
188178
},
189179
{
190180
config: 'web/app.css',
191181
content: [
192-
'{URL}/admin/**/*.{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}',
193-
'{URL}/web/*.bin',
194-
'{URL}/web/bar.bin',
182+
'{URL}/*',
183+
'{URL}/admin/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
195184
'{URL}/package.json',
196185
'{URL}/shared.html',
197-
'{URL}/web/**/*.{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}',
186+
'{URL}/web/bar.bin',
187+
'{URL}/web/{**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue},*.bin}',
198188
],
199189
},
200190
])
@@ -203,7 +193,7 @@ testFixture('v4/missing-files', [
203193
//
204194
{
205195
config: 'app.css',
206-
content: ['{URL}/package.json'],
196+
content: ['{URL}/*', '{URL}/package.json'],
207197
},
208198
])
209199

@@ -212,8 +202,9 @@ testFixture('v4/path-mappings', [
212202
{
213203
config: 'app.css',
214204
content: [
205+
'{URL}/*',
215206
'{URL}/package.json',
216-
'{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}',
207+
'{URL}/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
217208
'{URL}/src/a/my-config.ts',
218209
'{URL}/src/a/my-plugin.ts',
219210
'{URL}/tsconfig.json',
@@ -225,7 +216,7 @@ testFixture('v4/invalid-import-order', [
225216
//
226217
{
227218
config: 'tailwind.css',
228-
content: ['{URL}/package.json'],
219+
content: ['{URL}/*', '{URL}/package.json'],
229220
},
230221
])
231222

packages/vscode-tailwindcss/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Prerelease
44

5-
- Nothing yet!
5+
- Fix content detection when using v4.0+ ([#1280](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1280))
66

77
# 0.14.11
88

pnpm-lock.yaml

+55-45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)