Fix `files.exclude` merging (#464)

master
Brad Cornes 2022-01-17 14:07:55 +00:00
parent 5b675434f0
commit f40272fee2
1 changed files with 10 additions and 13 deletions

View File

@ -18,6 +18,7 @@ import {
TextEditorDecorationType, TextEditorDecorationType,
RelativePattern, RelativePattern,
ConfigurationScope, ConfigurationScope,
WorkspaceConfiguration,
} from 'vscode' } from 'vscode'
import { import {
LanguageClient, LanguageClient,
@ -83,15 +84,16 @@ function getUserLanguages(folder?: WorkspaceFolder): Record<string, string> {
return isObject(langs) ? langs : {} return isObject(langs) ? langs : {}
} }
function getExcludePatterns(folder: WorkspaceFolder): string[] { function getGlobalExcludePatterns(scope: ConfigurationScope): string[] {
let globalExclude = Workspace.getConfiguration('files', folder).get('exclude') return Object.entries(Workspace.getConfiguration('files', scope).get('exclude'))
let exclude = Object.entries(globalExclude) .filter(([, value]) => value === true)
.filter(([, value]) => value)
.map(([key]) => key) .map(([key]) => key)
}
function getExcludePatterns(scope: ConfigurationScope): string[] {
return [ return [
...exclude, ...getGlobalExcludePatterns(scope),
...(<string[]>Workspace.getConfiguration('tailwindCSS', folder).get('files.exclude')), ...(<string[]>Workspace.getConfiguration('tailwindCSS', scope).get('files.exclude')),
] ]
} }
@ -107,17 +109,12 @@ function isExcluded(file: string, folder: WorkspaceFolder): boolean {
return false return false
} }
function mergeExcludes(settings, scope) { function mergeExcludes(settings: WorkspaceConfiguration, scope: ConfigurationScope) {
// merge `files.exclude` into `tailwindCSS.files.exclude`
let globalExclude = Object.entries(Workspace.getConfiguration('files', scope).get('exclude'))
.filter(([, value]) => value)
.map(([key]) => key)
return { return {
...settings, ...settings,
files: { files: {
...settings.files, ...settings.files,
exclude: [...globalExclude, ...settings.files.exclude], exclude: [...getGlobalExcludePatterns(scope), ...settings.files.exclude],
}, },
} }
} }