File tree Expand file tree Collapse file tree 3 files changed +51
-3
lines changed
tailwindcss-language-server/src Expand file tree Collapse file tree 3 files changed +51
-3
lines changed Original file line number Diff line number Diff line change @@ -462,6 +462,43 @@ testLocator({
462462 ] ,
463463} )
464464
465+ testLocator ( {
466+ name : 'File exclusions starting with `/` do not cause traversal to loop forever' ,
467+ fs : {
468+ 'index.css' : css `
469+ @import 'tailwindcss';
470+ ` ,
471+ 'vendor/a.css' : css `
472+ @import 'tailwindcss';
473+ ` ,
474+ 'vendor/nested/b.css' : css `
475+ @import 'tailwindcss';
476+ ` ,
477+ 'src/vendor/c.css' : css `
478+ @import 'tailwindcss';
479+ ` ,
480+ } ,
481+ settings : {
482+ tailwindCSS : {
483+ files : {
484+ exclude : [ '/vendor' ] ,
485+ } ,
486+ } as Settings [ 'tailwindCSS' ] ,
487+ } ,
488+ expected : [
489+ {
490+ version : '4.1.1 (bundled)' ,
491+ config : '/index.css' ,
492+ content : [ ] ,
493+ } ,
494+ {
495+ version : '4.1.1 (bundled)' ,
496+ config : '/src/vendor/c.css' ,
497+ content : [ ] ,
498+ } ,
499+ ] ,
500+ } )
501+
465502// ---
466503
467504function testLocator ( {
@@ -502,7 +539,7 @@ function testLocator({
502539 } )
503540}
504541
505- async function prepare ( { root } : TestUtils ) {
542+ async function prepare ( { root } : TestUtils < any > ) {
506543 let defaultSettings = {
507544 tailwindCSS : {
508545 files : {
Original file line number Diff line number Diff line change @@ -274,11 +274,22 @@ export class ProjectLocator {
274274 }
275275
276276 private async findConfigs ( ) : Promise < ConfigEntry [ ] > {
277+ let ignore = this . settings . tailwindCSS . files . exclude
278+
279+ // NOTE: This is a temporary workaround for a bug in the `fdir` package used
280+ // by `tinyglobby`. It infinite loops when the ignore pattern starts with
281+ // a `/`. This should be removed once the bug is fixed.
282+ ignore = ignore . map ( ( pattern ) => {
283+ if ( ! pattern . startsWith ( '/' ) ) return pattern
284+
285+ return pattern . slice ( 1 )
286+ } )
287+
277288 // Look for config files and CSS files
278289 let files = await glob ( {
279290 patterns : [ `**/${ CONFIG_GLOB } ` , `**/${ CSS_GLOB } ` ] ,
280291 cwd : this . base ,
281- ignore : this . settings . tailwindCSS . files . exclude ,
292+ ignore,
282293 onlyFiles : true ,
283294 absolute : true ,
284295 followSymbolicLinks : true ,
Original file line number Diff line number Diff line change 22
33## Prerelease
44
5- - Nothing yet!
5+ - Prevent infinite loop when any file exclusion starts with ` / ` ( [ # 1307 ] ( https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1307 ) )
66
77# 0.14.14
88
You can’t perform that action at this time.
0 commit comments