Filter out empty `files.exclude` items

master
Brad Cornes 2022-01-24 12:21:15 +00:00
parent 85cf5edccb
commit e173a6fa64
2 changed files with 8 additions and 5 deletions

View File

@ -980,11 +980,11 @@ async function createProjectService(
dispose()
}
},
onUpdateSettings(settings: any): void {
async onUpdateSettings(settings: any): Promise<void> {
documentSettingsCache.clear()
let previousExclude =
state.editor.globalSettings.tailwindCSS.files?.exclude ?? DEFAULT_FILES_EXCLUDE
state.editor.globalSettings = settings
state.editor.globalSettings = await state.editor.getConfiguration()
if (!equal(previousExclude, settings.tailwindCSS.files?.exclude ?? DEFAULT_FILES_EXCLUDE)) {
tryInit()
} else {

View File

@ -88,12 +88,15 @@ function getGlobalExcludePatterns(scope: ConfigurationScope): string[] {
return Object.entries(Workspace.getConfiguration('files', scope).get('exclude'))
.filter(([, value]) => value === true)
.map(([key]) => key)
.filter(Boolean)
}
function getExcludePatterns(scope: ConfigurationScope): string[] {
return [
...getGlobalExcludePatterns(scope),
...(<string[]>Workspace.getConfiguration('tailwindCSS', scope).get('files.exclude')),
...(<string[]>Workspace.getConfiguration('tailwindCSS', scope).get('files.exclude')).filter(
Boolean
),
]
}
@ -109,12 +112,12 @@ function isExcluded(file: string, folder: WorkspaceFolder): boolean {
return false
}
function mergeExcludes(settings: WorkspaceConfiguration, scope: ConfigurationScope) {
function mergeExcludes(settings: WorkspaceConfiguration, scope: ConfigurationScope): any {
return {
...settings,
files: {
...settings.files,
exclude: [...getGlobalExcludePatterns(scope), ...settings.files.exclude],
exclude: getExcludePatterns(scope),
},
}
}