Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async _fetchSettingsForFolderUri(uri: string): Promise {
log(`fetchFolderSettings: URI ${uri}`);
const cSpellConfigSettings = await this.fetchSettingsFromVSCode(uri);
const cSpellFolderSettings = this.resolveConfigImports(cSpellConfigSettings, uri);
const settings = this._cspellFileSettingsByFolderCache.get(uri);
// cspell.json file settings take precedence over the vscode settings.
const mergedSettings = CSpell.mergeSettings(cSpellFolderSettings, settings);
const { ignorePaths = []} = mergedSettings;
const globs = defaultExclude.concat(ignorePaths);
const root = Uri.parse(uri).path;
const globMatcher = new GlobMatcher(globs, root);
const ext: ExtSettings = {
uri,
vscodeSettings: { cSpell: cSpellConfigSettings },
settings: mergedSettings,
globMatcher,
};
return ext;
}
function calcExcludeGlobInfo(root: string, commandLineExclude: string | undefined): GlobSrcInfo[] {
const commandLineExcludes = {
globs: commandLineExclude ? commandLineExclude.split(/\s+/g) : [],
source: 'arguments'
};
const defaultExcludes = {
globs: defaultExcludeGlobs,
source: 'default'
};
const choice = commandLineExcludes.globs.length ? commandLineExcludes : defaultExcludes;
const matcher = new GlobMatcher(choice.globs, root);
return [{
matcher,
source: choice.source
}];
}
function extractGlobExcludesFromConfig(root: string, source: string, config: cspell.CSpellUserSettings): GlobSrcInfo[] {
if (!config.ignorePaths || !config.ignorePaths.length) {
return [];
}
const matcher = new GlobMatcher(config.ignorePaths, root);
return [{ source, matcher }];
}