cspell-lib 5.15.2 → 5.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Models/CSpellSettingsInternalDef.d.ts +23 -0
- package/dist/Models/CSpellSettingsInternalDef.js +16 -0
- package/dist/Settings/CSpellSettingsServer.d.ts +47 -19
- package/dist/Settings/CSpellSettingsServer.js +107 -62
- package/dist/Settings/DefaultSettings.d.ts +3 -3
- package/dist/Settings/DefaultSettings.js +3 -2
- package/dist/Settings/DictionarySettings.d.ts +10 -13
- package/dist/Settings/DictionarySettings.js +7 -6
- package/dist/Settings/index.d.ts +4 -4
- package/dist/Settings/index.js +29 -14
- package/dist/Settings/index.link.d.ts +3 -0
- package/dist/Settings/index.link.js +8 -0
- package/dist/SpellingDictionary/Dictionaries.d.ts +4 -4
- package/dist/SpellingDictionary/Dictionaries.js +3 -3
- package/dist/SpellingDictionary/SpellingDictionary.d.ts +2 -1
- package/dist/SpellingDictionary/SpellingDictionaryFromTrie.d.ts +4 -2
- package/dist/SpellingDictionary/SpellingDictionaryFromTrie.js +3 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.js +16 -6
- package/dist/suggestions.d.ts +63 -0
- package/dist/suggestions.js +117 -0
- package/dist/trace.d.ts +1 -0
- package/dist/trace.js +19 -16
- package/dist/util/util.d.ts +3 -0
- package/dist/util/util.js +19 -1
- package/dist/validator.js +1 -2
- package/package.json +14 -11
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSpellSettingsWithSourceTrace, DictionaryDefinitionAugmented, DictionaryDefinitionCustom, DictionaryDefinitionPreferred } from '@cspell/cspell-types';
|
|
2
|
+
import { WeightMap } from 'cspell-trie-lib';
|
|
3
|
+
export declare const SymbolCSpellSettingsInternal: unique symbol;
|
|
4
|
+
export interface CSpellSettingsInternal extends Omit<CSpellSettingsWithSourceTrace, 'dictionaryDefinitions'> {
|
|
5
|
+
[SymbolCSpellSettingsInternal]: true;
|
|
6
|
+
dictionaryDefinitions?: DictionaryDefinitionInternal[];
|
|
7
|
+
}
|
|
8
|
+
declare type DictionaryDefinitionCustomUniqueFields = Omit<DictionaryDefinitionCustom, keyof DictionaryDefinitionPreferred>;
|
|
9
|
+
export interface DictionaryDefinitionInternal extends DictionaryDefinitionPreferred, Partial<DictionaryDefinitionCustomUniqueFields>, DictionaryDefinitionAugmented {
|
|
10
|
+
/**
|
|
11
|
+
* Optional weight map used to improve suggestions.
|
|
12
|
+
*/
|
|
13
|
+
weightMap?: WeightMap;
|
|
14
|
+
/** The path to the config file that contains this dictionary definition */
|
|
15
|
+
__source?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface DictionaryDefinitionInternalWithSource extends DictionaryDefinitionInternal {
|
|
18
|
+
__source: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function createCSpellSettingsInternal(parts?: Partial<CSpellSettingsInternal>): CSpellSettingsInternal;
|
|
21
|
+
export declare function isCSpellSettingsInternal(cs: CSpellSettingsInternal | CSpellSettingsWithSourceTrace): cs is CSpellSettingsInternal;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=CSpellSettingsInternalDef.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCSpellSettingsInternal = exports.createCSpellSettingsInternal = exports.SymbolCSpellSettingsInternal = void 0;
|
|
4
|
+
exports.SymbolCSpellSettingsInternal = Symbol('CSpellSettingsInternal');
|
|
5
|
+
function createCSpellSettingsInternal(parts = {}) {
|
|
6
|
+
return {
|
|
7
|
+
...parts,
|
|
8
|
+
[exports.SymbolCSpellSettingsInternal]: true,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.createCSpellSettingsInternal = createCSpellSettingsInternal;
|
|
12
|
+
function isCSpellSettingsInternal(cs) {
|
|
13
|
+
return !!cs[exports.SymbolCSpellSettingsInternal];
|
|
14
|
+
}
|
|
15
|
+
exports.isCSpellSettingsInternal = isCSpellSettingsInternal;
|
|
16
|
+
//# sourceMappingURL=CSpellSettingsInternalDef.js.map
|
|
@@ -1,62 +1,90 @@
|
|
|
1
1
|
import type { CSpellSettingsWithSourceTrace, CSpellUserSettings, Glob, ImportFileRef, PnPSettings } from '@cspell/cspell-types';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
|
+
import { CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef';
|
|
3
4
|
import { LoaderResult } from './pnpLoader';
|
|
5
|
+
declare type CSpellSettingsWST = CSpellSettingsWithSourceTrace;
|
|
6
|
+
declare type CSpellSettingsI = CSpellSettingsInternal;
|
|
4
7
|
export declare const currentSettingsFileVersion = "0.2";
|
|
5
8
|
export declare const sectionCSpell = "cSpell";
|
|
6
9
|
export declare const defaultFileName = "cspell.json";
|
|
7
10
|
export declare const ENV_CSPELL_GLOB_ROOT = "CSPELL_GLOB_ROOT";
|
|
8
11
|
export declare const defaultConfigFilenames: readonly string[];
|
|
9
|
-
declare type CSpellSettings = CSpellSettingsWithSourceTrace;
|
|
10
12
|
/**
|
|
11
13
|
* normalizeSettings handles correcting all relative paths, anchoring globs, and importing other config files.
|
|
12
14
|
* @param rawSettings - raw configuration settings
|
|
13
15
|
* @param pathToSettingsFile - path to the source file of the configuration settings.
|
|
14
16
|
*/
|
|
15
|
-
declare function normalizeSettings(rawSettings:
|
|
16
|
-
export declare function readSettings(filename: string):
|
|
17
|
-
export declare function readSettings(filename: string, defaultValues:
|
|
18
|
-
export declare function readSettings(filename: string, relativeTo: string):
|
|
19
|
-
export declare function readSettings(filename: string, relativeTo: string, defaultValues:
|
|
20
|
-
export declare function searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettings): Promise<
|
|
21
|
-
|
|
17
|
+
declare function normalizeSettings(rawSettings: CSpellSettingsWST, pathToSettingsFile: string, pnpSettings: PnPSettings): CSpellSettingsI;
|
|
18
|
+
export declare function readSettings(filename: string): CSpellSettingsI;
|
|
19
|
+
export declare function readSettings(filename: string, defaultValues: CSpellSettingsWST): CSpellSettingsI;
|
|
20
|
+
export declare function readSettings(filename: string, relativeTo: string): CSpellSettingsI;
|
|
21
|
+
export declare function readSettings(filename: string, relativeTo: string, defaultValues: CSpellSettingsWST): CSpellSettingsI;
|
|
22
|
+
export declare function searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettings): Promise<CSpellSettingsI | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* Load a CSpell configuration files.
|
|
25
|
+
* @param file - path or package reference to load.
|
|
26
|
+
* @param pnpSettings - PnP settings
|
|
27
|
+
* @returns normalized CSpellSettings
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadConfig(file: string, pnpSettings?: PnPSettings): Promise<CSpellSettingsI>;
|
|
22
30
|
export declare function loadPnP(pnpSettings: PnPSettings, searchFrom: URI): Promise<LoaderResult>;
|
|
23
31
|
export declare function loadPnPSync(pnpSettings: PnPSettings, searchFrom: URI): LoaderResult;
|
|
24
|
-
export declare function readRawSettings(filename: string, relativeTo?: string):
|
|
32
|
+
export declare function readRawSettings(filename: string, relativeTo?: string): CSpellSettingsWST;
|
|
25
33
|
/**
|
|
26
34
|
*
|
|
27
35
|
* @param filenames - settings files to read
|
|
28
36
|
* @returns combined configuration
|
|
29
37
|
* @deprecated true
|
|
30
38
|
*/
|
|
31
|
-
export declare function readSettingsFiles(filenames: string[]):
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export declare function
|
|
39
|
+
export declare function readSettingsFiles(filenames: string[]): CSpellSettingsI;
|
|
40
|
+
declare function mergeObjects(left: undefined, right: undefined): undefined;
|
|
41
|
+
declare function mergeObjects<T>(left: T, right: undefined): T;
|
|
42
|
+
declare function mergeObjects<T>(left: T, right: T): T;
|
|
43
|
+
declare function mergeObjects<T>(left: undefined, right: T): T;
|
|
44
|
+
export declare function mergeSettings(left: CSpellSettingsWST | CSpellSettingsI, ...settings: (CSpellSettingsWST | CSpellSettingsI)[]): CSpellSettingsI;
|
|
45
|
+
export declare function mergeInDocSettings(left: CSpellSettingsWST, right: CSpellSettingsWST): CSpellSettingsWST;
|
|
46
|
+
export declare function calcOverrideSettings(settings: CSpellSettingsWST, filename: string): CSpellSettingsI;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param settings - settings to finalize
|
|
50
|
+
* @returns settings where all globs and file paths have been resolved.
|
|
51
|
+
*/
|
|
52
|
+
export declare function finalizeSettings(settings: CSpellSettingsWST | CSpellSettingsI): CSpellSettingsI;
|
|
53
|
+
export declare function toInternalSettings(settings: undefined): undefined;
|
|
54
|
+
export declare function toInternalSettings(settings: CSpellSettingsI | CSpellSettingsWST): CSpellSettingsI;
|
|
55
|
+
export declare function toInternalSettings(settings?: CSpellSettingsI | CSpellSettingsWST): CSpellSettingsI | undefined;
|
|
56
|
+
export declare function getGlobalSettings(): CSpellSettingsI;
|
|
37
57
|
export declare function getCachedFileSize(): number;
|
|
38
58
|
export declare function clearCachedSettingsFiles(): void;
|
|
59
|
+
/**
|
|
60
|
+
* @param filename - filename
|
|
61
|
+
* @param globs - globs
|
|
62
|
+
* @returns true if it matches
|
|
63
|
+
* @deprecated true
|
|
64
|
+
* @deprecationMessage No longer actively supported. Use package: `cspell-glob`.
|
|
65
|
+
*/
|
|
39
66
|
export declare function checkFilenameMatchesGlob(filename: string, globs: Glob | Glob[]): boolean;
|
|
40
67
|
/**
|
|
41
68
|
* Return a list of Setting Sources used to create this Setting.
|
|
42
69
|
* @param settings the settings to search
|
|
43
70
|
*/
|
|
44
|
-
export declare function getSources(settings:
|
|
71
|
+
export declare function getSources(settings: CSpellSettingsWST): CSpellSettingsWST[];
|
|
45
72
|
export interface ImportFileRefWithError extends ImportFileRef {
|
|
46
73
|
error: Error;
|
|
47
74
|
}
|
|
48
|
-
export declare function extractImportErrors(settings:
|
|
75
|
+
export declare function extractImportErrors(settings: CSpellSettingsWST): ImportFileRefWithError[];
|
|
49
76
|
export interface ConfigurationDependencies {
|
|
50
77
|
configFiles: string[];
|
|
51
78
|
dictionaryFiles: string[];
|
|
52
79
|
}
|
|
53
|
-
export declare function extractDependencies(settings:
|
|
54
|
-
declare function normalizeCacheSettings(settings: Pick<
|
|
80
|
+
export declare function extractDependencies(settings: CSpellSettingsWST | CSpellSettingsI): ConfigurationDependencies;
|
|
81
|
+
declare function normalizeCacheSettings(settings: Pick<CSpellUserSettings, 'cache'>, pathToSettingsDir: string): Pick<CSpellUserSettings, 'cache'>;
|
|
55
82
|
declare function validateRawConfigVersion(config: CSpellUserSettings | {
|
|
56
83
|
version: unknown;
|
|
57
84
|
}, fileRef: ImportFileRef): void;
|
|
58
85
|
declare function validateRawConfigExports(config: CSpellUserSettings, fileRef: ImportFileRef): void;
|
|
59
86
|
export declare const __testing__: {
|
|
87
|
+
mergeObjects: typeof mergeObjects;
|
|
60
88
|
normalizeCacheSettings: typeof normalizeCacheSettings;
|
|
61
89
|
normalizeSettings: typeof normalizeSettings;
|
|
62
90
|
validateRawConfigExports: typeof validateRawConfigExports;
|
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.__testing__ = exports.extractDependencies = exports.extractImportErrors = exports.getSources = exports.checkFilenameMatchesGlob = exports.clearCachedSettingsFiles = exports.getCachedFileSize = exports.getGlobalSettings = exports.finalizeSettings = exports.calcOverrideSettings = exports.mergeInDocSettings = exports.mergeSettings = exports.readSettingsFiles = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.searchForConfig = exports.readSettings = exports.defaultConfigFilenames = exports.ENV_CSPELL_GLOB_ROOT = exports.defaultFileName = exports.sectionCSpell = exports.currentSettingsFileVersion = void 0;
|
|
22
|
+
exports.__testing__ = exports.extractDependencies = exports.extractImportErrors = exports.getSources = exports.checkFilenameMatchesGlob = exports.clearCachedSettingsFiles = exports.getCachedFileSize = exports.getGlobalSettings = exports.toInternalSettings = exports.finalizeSettings = exports.calcOverrideSettings = exports.mergeInDocSettings = exports.mergeSettings = exports.readSettingsFiles = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.searchForConfig = exports.readSettings = exports.defaultConfigFilenames = exports.ENV_CSPELL_GLOB_ROOT = exports.defaultFileName = exports.sectionCSpell = exports.currentSettingsFileVersion = void 0;
|
|
23
23
|
const json = __importStar(require("comment-json"));
|
|
24
24
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
25
25
|
const cspell_glob_1 = require("cspell-glob");
|
|
@@ -28,6 +28,7 @@ const vscode_uri_1 = require("vscode-uri");
|
|
|
28
28
|
const logger_1 = require("../util/logger");
|
|
29
29
|
const resolveFile_1 = require("../util/resolveFile");
|
|
30
30
|
const util = __importStar(require("../util/util"));
|
|
31
|
+
const CSpellSettingsInternalDef_1 = require("../Models/CSpellSettingsInternalDef");
|
|
31
32
|
const DictionarySettings_1 = require("./DictionarySettings");
|
|
32
33
|
const GlobalSettings_1 = require("./GlobalSettings");
|
|
33
34
|
const ImportError_1 = require("./ImportError");
|
|
@@ -87,11 +88,11 @@ function parseJson(_filename, content) {
|
|
|
87
88
|
exports.defaultConfigFilenames = Object.freeze(searchPlaces.concat());
|
|
88
89
|
const cspellConfigExplorer = (0, cosmiconfig_1.cosmiconfig)('cspell', cspellCosmiconfig);
|
|
89
90
|
const cspellConfigExplorerSync = (0, cosmiconfig_1.cosmiconfigSync)('cspell', cspellCosmiconfig);
|
|
90
|
-
const defaultSettings = {
|
|
91
|
+
const defaultSettings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({
|
|
91
92
|
id: 'default',
|
|
92
93
|
name: 'default',
|
|
93
94
|
version: exports.currentSettingsFileVersion,
|
|
94
|
-
};
|
|
95
|
+
});
|
|
95
96
|
const defaultPnPSettings = {};
|
|
96
97
|
let globalSettings;
|
|
97
98
|
const cachedFiles = new Map();
|
|
@@ -156,7 +157,7 @@ function normalizeSettings(rawSettings, pathToSettingsFile, pnpSettings) {
|
|
|
156
157
|
name: settings.name,
|
|
157
158
|
filename: pathToSettingsFile,
|
|
158
159
|
};
|
|
159
|
-
const fileSettings = {
|
|
160
|
+
const fileSettings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({
|
|
160
161
|
...settings,
|
|
161
162
|
source,
|
|
162
163
|
...normalizedDictionaryDefs,
|
|
@@ -165,7 +166,7 @@ function normalizeSettings(rawSettings, pathToSettingsFile, pnpSettings) {
|
|
|
165
166
|
...normalizedReporters,
|
|
166
167
|
...normalizedGitignoreRoot,
|
|
167
168
|
...normalizedCacheSettings,
|
|
168
|
-
};
|
|
169
|
+
});
|
|
169
170
|
if (!imports.length) {
|
|
170
171
|
return fileSettings;
|
|
171
172
|
}
|
|
@@ -203,7 +204,7 @@ function importSettings(fileRef, defaultValues, pnpSettings) {
|
|
|
203
204
|
}
|
|
204
205
|
const id = [path.basename(path.dirname(filename)), path.basename(filename)].join('/');
|
|
205
206
|
const name = id;
|
|
206
|
-
const finalizeSettings = { id, name, __importRef: importRef };
|
|
207
|
+
const finalizeSettings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({ id, name, __importRef: importRef });
|
|
207
208
|
cachedFiles.set(filename, finalizeSettings); // add an empty entry to prevent circular references.
|
|
208
209
|
const settings = { ...defaultValues, id, name, ...readConfig(importRef) };
|
|
209
210
|
Object.assign(finalizeSettings, normalizeSettings(settings, filename, pnpSettings));
|
|
@@ -240,12 +241,12 @@ async function normalizeSearchForConfigResult(searchPath, searchResult, pnpSetti
|
|
|
240
241
|
};
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
|
-
const { config = {} } = result || {};
|
|
244
|
+
const { config = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({}) } = result || {};
|
|
244
245
|
const filename = (_a = result === null || result === void 0 ? void 0 : result.filepath) !== null && _a !== void 0 ? _a : searchPath;
|
|
245
246
|
const importRef = { filename: filename, error };
|
|
246
247
|
const id = [path.basename(path.dirname(filename)), path.basename(filename)].join('/');
|
|
247
248
|
const name = (result === null || result === void 0 ? void 0 : result.filepath) ? id : `Config not found: ${id}`;
|
|
248
|
-
const finalizeSettings = { id, name, __importRef: importRef };
|
|
249
|
+
const finalizeSettings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({ id, name, __importRef: importRef });
|
|
249
250
|
const settings = { id, ...config };
|
|
250
251
|
cachedFiles.set(filename, finalizeSettings); // add an empty entry to prevent circular references.
|
|
251
252
|
Object.assign(finalizeSettings, normalizeSettings(settings, filename, pnpSettings));
|
|
@@ -259,6 +260,12 @@ function searchForConfig(searchFrom, pnpSettings = defaultPnPSettings) {
|
|
|
259
260
|
return normalizeSearchForConfigResult(searchFrom || process.cwd(), cspellConfigExplorer.search(searchFrom), pnpSettings).then((r) => (r.filepath ? r.config : undefined));
|
|
260
261
|
}
|
|
261
262
|
exports.searchForConfig = searchForConfig;
|
|
263
|
+
/**
|
|
264
|
+
* Load a CSpell configuration files.
|
|
265
|
+
* @param file - path or package reference to load.
|
|
266
|
+
* @param pnpSettings - PnP settings
|
|
267
|
+
* @returns normalized CSpellSettings
|
|
268
|
+
*/
|
|
262
269
|
function loadConfig(file, pnpSettings = defaultPnPSettings) {
|
|
263
270
|
const cached = cachedFiles.get(path.resolve(file));
|
|
264
271
|
if (cached) {
|
|
@@ -314,6 +321,13 @@ function mergeList(left, right) {
|
|
|
314
321
|
return left;
|
|
315
322
|
return left.concat(right);
|
|
316
323
|
}
|
|
324
|
+
function mergeObjects(left, right) {
|
|
325
|
+
if (left === undefined)
|
|
326
|
+
return right;
|
|
327
|
+
if (right === undefined)
|
|
328
|
+
return left;
|
|
329
|
+
return { ...left, ...right };
|
|
330
|
+
}
|
|
317
331
|
function tagLanguageSettings(tag, settings = []) {
|
|
318
332
|
return settings.map((s) => ({
|
|
319
333
|
id: tag + '.' + (s.id || s.locale || s.languageId),
|
|
@@ -328,7 +342,7 @@ function replaceIfNotEmpty(left = [], right = []) {
|
|
|
328
342
|
return left;
|
|
329
343
|
}
|
|
330
344
|
function mergeSettings(left, ...settings) {
|
|
331
|
-
const rawSettings = settings.reduce(merge, left);
|
|
345
|
+
const rawSettings = settings.reduce(merge, toInternalSettings(left));
|
|
332
346
|
return util.clean(rawSettings);
|
|
333
347
|
}
|
|
334
348
|
exports.mergeSettings = mergeSettings;
|
|
@@ -337,55 +351,59 @@ function isEmpty(obj) {
|
|
|
337
351
|
return Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
338
352
|
}
|
|
339
353
|
function merge(left, right) {
|
|
354
|
+
const _left = toInternalSettings(left);
|
|
355
|
+
const _right = toInternalSettings(right);
|
|
340
356
|
if (left === right) {
|
|
341
|
-
return
|
|
357
|
+
return _left;
|
|
342
358
|
}
|
|
343
359
|
if (isEmpty(right)) {
|
|
344
|
-
return
|
|
360
|
+
return _left;
|
|
345
361
|
}
|
|
346
362
|
if (isEmpty(left)) {
|
|
347
|
-
return
|
|
363
|
+
return _right;
|
|
348
364
|
}
|
|
349
|
-
if (isLeftAncestorOfRight(
|
|
350
|
-
return
|
|
365
|
+
if (isLeftAncestorOfRight(_left, _right)) {
|
|
366
|
+
return _right;
|
|
351
367
|
}
|
|
352
|
-
if (doesLeftHaveRightAncestor(
|
|
353
|
-
return
|
|
368
|
+
if (doesLeftHaveRightAncestor(_left, _right)) {
|
|
369
|
+
return _left;
|
|
354
370
|
}
|
|
355
|
-
const leftId =
|
|
356
|
-
const rightId =
|
|
357
|
-
const includeRegExpList = takeRightOtherwiseLeft(
|
|
371
|
+
const leftId = _left.id || _left.languageId || '';
|
|
372
|
+
const rightId = _right.id || _right.languageId || '';
|
|
373
|
+
const includeRegExpList = takeRightOtherwiseLeft(_left.includeRegExpList, _right.includeRegExpList);
|
|
358
374
|
const optionals = (includeRegExpList === null || includeRegExpList === void 0 ? void 0 : includeRegExpList.length) ? { includeRegExpList } : {};
|
|
359
|
-
const version = max(
|
|
360
|
-
const settings = {
|
|
361
|
-
...
|
|
362
|
-
...
|
|
375
|
+
const version = max(_left.version, _right.version);
|
|
376
|
+
const settings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({
|
|
377
|
+
..._left,
|
|
378
|
+
..._right,
|
|
363
379
|
...optionals,
|
|
364
380
|
version,
|
|
365
381
|
id: [leftId, rightId].join('|'),
|
|
366
|
-
name: [
|
|
367
|
-
words: mergeList(
|
|
368
|
-
userWords: mergeList(
|
|
369
|
-
flagWords: mergeListUnique(
|
|
370
|
-
ignoreWords: mergeListUnique(
|
|
371
|
-
enabledLanguageIds: replaceIfNotEmpty(
|
|
372
|
-
enableFiletypes: mergeList(
|
|
373
|
-
ignoreRegExpList: mergeListUnique(
|
|
374
|
-
patterns: mergeListUnique(
|
|
375
|
-
dictionaryDefinitions: mergeListUnique(
|
|
376
|
-
dictionaries: mergeListUnique(
|
|
377
|
-
noSuggestDictionaries: mergeListUnique(
|
|
378
|
-
languageSettings: mergeList(tagLanguageSettings(leftId,
|
|
379
|
-
enabled:
|
|
380
|
-
files: mergeListUnique(
|
|
381
|
-
ignorePaths: versionBasedMergeList(
|
|
382
|
-
overrides: versionBasedMergeList(
|
|
383
|
-
|
|
382
|
+
name: [_left.name || '', _right.name || ''].join('|'),
|
|
383
|
+
words: mergeList(_left.words, _right.words),
|
|
384
|
+
userWords: mergeList(_left.userWords, _right.userWords),
|
|
385
|
+
flagWords: mergeListUnique(_left.flagWords, _right.flagWords),
|
|
386
|
+
ignoreWords: mergeListUnique(_left.ignoreWords, _right.ignoreWords),
|
|
387
|
+
enabledLanguageIds: replaceIfNotEmpty(_left.enabledLanguageIds, _right.enabledLanguageIds),
|
|
388
|
+
enableFiletypes: mergeList(_left.enableFiletypes, _right.enableFiletypes),
|
|
389
|
+
ignoreRegExpList: mergeListUnique(_left.ignoreRegExpList, _right.ignoreRegExpList),
|
|
390
|
+
patterns: mergeListUnique(_left.patterns, _right.patterns),
|
|
391
|
+
dictionaryDefinitions: mergeListUnique(_left.dictionaryDefinitions, _right.dictionaryDefinitions),
|
|
392
|
+
dictionaries: mergeListUnique(_left.dictionaries, _right.dictionaries),
|
|
393
|
+
noSuggestDictionaries: mergeListUnique(_left.noSuggestDictionaries, _right.noSuggestDictionaries),
|
|
394
|
+
languageSettings: mergeList(tagLanguageSettings(leftId, _left.languageSettings), tagLanguageSettings(rightId, _right.languageSettings)),
|
|
395
|
+
enabled: _right.enabled !== undefined ? _right.enabled : _left.enabled,
|
|
396
|
+
files: mergeListUnique(_left.files, _right.files),
|
|
397
|
+
ignorePaths: versionBasedMergeList(_left.ignorePaths, _right.ignorePaths, version),
|
|
398
|
+
overrides: versionBasedMergeList(_left.overrides, _right.overrides, version),
|
|
399
|
+
features: mergeObjects(_left.features, _right.features),
|
|
400
|
+
source: mergeSources(_left, _right),
|
|
401
|
+
description: undefined,
|
|
384
402
|
globRoot: undefined,
|
|
385
403
|
import: undefined,
|
|
386
|
-
__imports: mergeImportRefs(
|
|
404
|
+
__imports: mergeImportRefs(_left, _right),
|
|
387
405
|
__importRef: undefined,
|
|
388
|
-
};
|
|
406
|
+
});
|
|
389
407
|
return settings;
|
|
390
408
|
}
|
|
391
409
|
function versionBasedMergeList(left, right, version) {
|
|
@@ -437,14 +455,24 @@ function takeRightOtherwiseLeft(left, right) {
|
|
|
437
455
|
return left || right;
|
|
438
456
|
}
|
|
439
457
|
function calcOverrideSettings(settings, filename) {
|
|
440
|
-
const
|
|
458
|
+
const _settings = toInternalSettings(settings);
|
|
459
|
+
const overrides = _settings.overrides || [];
|
|
441
460
|
const result = overrides
|
|
442
461
|
.filter((override) => checkFilenameMatchesGlob(filename, override.filename))
|
|
443
|
-
.reduce((settings, override) => mergeSettings(settings, override),
|
|
462
|
+
.reduce((settings, override) => mergeSettings(settings, override), _settings);
|
|
444
463
|
return result;
|
|
445
464
|
}
|
|
446
465
|
exports.calcOverrideSettings = calcOverrideSettings;
|
|
466
|
+
/**
|
|
467
|
+
*
|
|
468
|
+
* @param settings - settings to finalize
|
|
469
|
+
* @returns settings where all globs and file paths have been resolved.
|
|
470
|
+
*/
|
|
447
471
|
function finalizeSettings(settings) {
|
|
472
|
+
return _finalizeSettings(toInternalSettings(settings));
|
|
473
|
+
}
|
|
474
|
+
exports.finalizeSettings = finalizeSettings;
|
|
475
|
+
function _finalizeSettings(settings) {
|
|
448
476
|
// apply patterns to any RegExpLists.
|
|
449
477
|
const finalized = {
|
|
450
478
|
...settings,
|
|
@@ -455,7 +483,21 @@ function finalizeSettings(settings) {
|
|
|
455
483
|
finalized.source = { name: settings.name || 'src', sources: [settings] };
|
|
456
484
|
return finalized;
|
|
457
485
|
}
|
|
458
|
-
|
|
486
|
+
function toInternalSettings(settings) {
|
|
487
|
+
var _a;
|
|
488
|
+
if (settings === undefined)
|
|
489
|
+
return undefined;
|
|
490
|
+
if ((0, CSpellSettingsInternalDef_1.isCSpellSettingsInternal)(settings))
|
|
491
|
+
return settings;
|
|
492
|
+
const { dictionaryDefinitions: defs, ...rest } = settings;
|
|
493
|
+
const dictionaryDefinitions = (0, DictionarySettings_1.mapDictDefsToInternal)(defs, filenameToDirectory((_a = settings.source) === null || _a === void 0 ? void 0 : _a.filename) || resolveCwd());
|
|
494
|
+
const setting = dictionaryDefinitions ? { ...rest, dictionaryDefinitions } : rest;
|
|
495
|
+
return (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)(setting);
|
|
496
|
+
}
|
|
497
|
+
exports.toInternalSettings = toInternalSettings;
|
|
498
|
+
function filenameToDirectory(filename) {
|
|
499
|
+
return filename ? path.dirname(filename) : undefined;
|
|
500
|
+
}
|
|
459
501
|
function resolveFilename(filename, relativeTo) {
|
|
460
502
|
const r = (0, resolveFile_1.resolveFile)(filename, relativeTo);
|
|
461
503
|
return {
|
|
@@ -485,18 +527,15 @@ function clearCachedSettingsFiles() {
|
|
|
485
527
|
cspellConfigExplorerSync.clearCaches();
|
|
486
528
|
}
|
|
487
529
|
exports.clearCachedSettingsFiles = clearCachedSettingsFiles;
|
|
488
|
-
|
|
489
|
-
|
|
530
|
+
/**
|
|
531
|
+
* @param filename - filename
|
|
532
|
+
* @param globs - globs
|
|
533
|
+
* @returns true if it matches
|
|
534
|
+
* @deprecated true
|
|
535
|
+
* @deprecationMessage No longer actively supported. Use package: `cspell-glob`.
|
|
536
|
+
*/
|
|
490
537
|
function checkFilenameMatchesGlob(filename, globs) {
|
|
491
|
-
const matcher = globMatcherCache.get(globs);
|
|
492
|
-
if (matcher) {
|
|
493
|
-
return matcher.match(filename);
|
|
494
|
-
}
|
|
495
|
-
if (globMatcherCache.size >= globMatcherCacheMaxSize) {
|
|
496
|
-
globMatcherCache.clear();
|
|
497
|
-
}
|
|
498
538
|
const m = new cspell_glob_1.GlobMatcher(globs);
|
|
499
|
-
globMatcherCache.set(globs, m);
|
|
500
539
|
return m.match(filename);
|
|
501
540
|
}
|
|
502
541
|
exports.checkFilenameMatchesGlob = checkFilenameMatchesGlob;
|
|
@@ -561,28 +600,33 @@ function extractImportErrors(settings) {
|
|
|
561
600
|
}
|
|
562
601
|
exports.extractImportErrors = extractImportErrors;
|
|
563
602
|
function extractDependencies(settings) {
|
|
564
|
-
const
|
|
565
|
-
const
|
|
603
|
+
const settingsI = toInternalSettings(settings);
|
|
604
|
+
const configFiles = [...(mergeImportRefs(settingsI) || [])].map(([filename]) => filename);
|
|
605
|
+
const dictionaryFiles = (0, DictionarySettings_1.calcDictionaryDefsToLoad)(settingsI).map((dict) => dict.path);
|
|
566
606
|
return {
|
|
567
607
|
configFiles,
|
|
568
608
|
dictionaryFiles,
|
|
569
609
|
};
|
|
570
610
|
}
|
|
571
611
|
exports.extractDependencies = extractDependencies;
|
|
612
|
+
function resolveCwd() {
|
|
613
|
+
const envGlobRoot = process.env[exports.ENV_CSPELL_GLOB_ROOT];
|
|
614
|
+
const cwd = envGlobRoot || process.cwd();
|
|
615
|
+
return cwd;
|
|
616
|
+
}
|
|
572
617
|
function resolveGlobRoot(settings, pathToSettingsFile) {
|
|
573
618
|
var _a;
|
|
574
619
|
const settingsFileDirRaw = path.dirname(pathToSettingsFile);
|
|
575
620
|
const isVSCode = path.basename(settingsFileDirRaw) === '.vscode';
|
|
576
621
|
const settingsFileDir = isVSCode ? path.dirname(settingsFileDirRaw) : settingsFileDirRaw;
|
|
577
622
|
const envGlobRoot = process.env[exports.ENV_CSPELL_GLOB_ROOT];
|
|
578
|
-
const cwd = envGlobRoot || process.cwd();
|
|
579
623
|
const defaultGlobRoot = envGlobRoot !== null && envGlobRoot !== void 0 ? envGlobRoot : '${cwd}';
|
|
580
624
|
const rawRoot = (_a = settings.globRoot) !== null && _a !== void 0 ? _a : (settings.version === configSettingsFileVersion0_1 ||
|
|
581
625
|
(envGlobRoot && !settings.version) ||
|
|
582
626
|
(isVSCode && !settings.version)
|
|
583
627
|
? defaultGlobRoot
|
|
584
628
|
: settingsFileDir);
|
|
585
|
-
const globRoot =
|
|
629
|
+
const globRoot = rawRoot.startsWith('${cwd}') ? rawRoot : path.resolve(settingsFileDir, rawRoot);
|
|
586
630
|
return globRoot;
|
|
587
631
|
}
|
|
588
632
|
function resolveFilePath(filename, pathToSettingsFile) {
|
|
@@ -608,10 +652,10 @@ function toGlobDef(g, root, source) {
|
|
|
608
652
|
}
|
|
609
653
|
function normalizeDictionaryDefs(settings, pathToSettingsFile) {
|
|
610
654
|
var _a;
|
|
611
|
-
const dictionaryDefinitions = (0, DictionarySettings_1.
|
|
655
|
+
const dictionaryDefinitions = (0, DictionarySettings_1.mapDictDefsToInternal)(settings.dictionaryDefinitions, pathToSettingsFile);
|
|
612
656
|
const languageSettings = (_a = settings.languageSettings) === null || _a === void 0 ? void 0 : _a.map((langSetting) => util.clean({
|
|
613
657
|
...langSetting,
|
|
614
|
-
dictionaryDefinitions: (0, DictionarySettings_1.
|
|
658
|
+
dictionaryDefinitions: (0, DictionarySettings_1.mapDictDefsToInternal)(langSetting.dictionaryDefinitions, pathToSettingsFile),
|
|
615
659
|
}));
|
|
616
660
|
return util.clean({
|
|
617
661
|
dictionaryDefinitions,
|
|
@@ -732,6 +776,7 @@ function validateRawConfig(config, fileRef) {
|
|
|
732
776
|
validations.forEach((fn) => fn(config, fileRef));
|
|
733
777
|
}
|
|
734
778
|
exports.__testing__ = {
|
|
779
|
+
mergeObjects,
|
|
735
780
|
normalizeCacheSettings,
|
|
736
781
|
normalizeSettings,
|
|
737
782
|
validateRawConfigExports,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const _defaultSettings: Readonly<
|
|
3
|
-
export declare function getDefaultSettings():
|
|
1
|
+
import { CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef';
|
|
2
|
+
export declare const _defaultSettings: Readonly<CSpellSettingsInternal>;
|
|
3
|
+
export declare function getDefaultSettings(): CSpellSettingsInternal;
|
|
4
4
|
//# sourceMappingURL=DefaultSettings.d.ts.map
|
|
@@ -21,6 +21,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.getDefaultSettings = exports._defaultSettings = void 0;
|
|
23
23
|
const resolveFile_1 = require("../util/resolveFile");
|
|
24
|
+
const CSpellSettingsInternalDef_1 = require("../Models/CSpellSettingsInternalDef");
|
|
24
25
|
const CSpellSettingsServer_1 = require("./CSpellSettingsServer");
|
|
25
26
|
const index_1 = require("./index");
|
|
26
27
|
const LanguageSettings = __importStar(require("./LanguageSettings"));
|
|
@@ -87,7 +88,7 @@ const definedDefaultRegExpExcludeList = [
|
|
|
87
88
|
];
|
|
88
89
|
// This bit of copying is done to have the complier ensure that the defaults exist.
|
|
89
90
|
const defaultRegExpExcludeList = definedDefaultRegExpExcludeList;
|
|
90
|
-
exports._defaultSettings = {
|
|
91
|
+
exports._defaultSettings = Object.freeze((0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({
|
|
91
92
|
id: 'static_defaults',
|
|
92
93
|
language: 'en',
|
|
93
94
|
name: 'Static Defaults',
|
|
@@ -131,7 +132,7 @@ exports._defaultSettings = {
|
|
|
131
132
|
languageSettings: LanguageSettings.getDefaultLanguageSettings(),
|
|
132
133
|
source: { name: 'defaultSettings' },
|
|
133
134
|
reporters: [],
|
|
134
|
-
};
|
|
135
|
+
}));
|
|
135
136
|
const getSettings = (function () {
|
|
136
137
|
let settings = undefined;
|
|
137
138
|
return function () {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { DictionaryDefinition,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__source: string;
|
|
5
|
-
}
|
|
6
|
-
export declare type DefMapArrayItem = [string, DictionaryDefinitionPreferred];
|
|
1
|
+
import type { DictionaryDefinition, DictionaryReference } from '@cspell/cspell-types';
|
|
2
|
+
import { CSpellSettingsInternal, DictionaryDefinitionInternal, DictionaryDefinitionInternalWithSource } from '../Models/CSpellSettingsInternalDef';
|
|
3
|
+
export declare type DefMapArrayItem = [string, DictionaryDefinitionInternal];
|
|
7
4
|
/**
|
|
8
5
|
* Combines the list of desired dictionaries with the list of dictionary
|
|
9
6
|
* definitions. Order does not matter, but the number of leading `!` does.
|
|
@@ -16,11 +13,11 @@ export declare type DefMapArrayItem = [string, DictionaryDefinitionPreferred];
|
|
|
16
13
|
* @param defs - dictionary definitions
|
|
17
14
|
* @returns map from dictIds to definitions
|
|
18
15
|
*/
|
|
19
|
-
export declare function filterDictDefsToLoad(dictRefIds: DictionaryReference[], defs:
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function isDictionaryDefinitionWithSource(d: DictionaryDefinition |
|
|
25
|
-
export declare function calcDictionaryDefsToLoad(settings:
|
|
16
|
+
export declare function filterDictDefsToLoad(dictRefIds: DictionaryReference[], defs: DictionaryDefinitionInternal[]): DictionaryDefinitionInternal[];
|
|
17
|
+
export declare function mapDictDefsToInternal(defs: undefined, pathToSettingsFile: string): undefined;
|
|
18
|
+
export declare function mapDictDefsToInternal(defs: DictionaryDefinition[], pathToSettingsFile: string): DictionaryDefinitionInternalWithSource[];
|
|
19
|
+
export declare function mapDictDefsToInternal(defs: DictionaryDefinition[] | undefined, pathToSettingsFile: string): DictionaryDefinitionInternalWithSource[] | undefined;
|
|
20
|
+
export declare function mapDictDefToInternal(def: DictionaryDefinition, pathToSettingsFile: string): DictionaryDefinitionInternalWithSource;
|
|
21
|
+
export declare function isDictionaryDefinitionWithSource(d: DictionaryDefinition | DictionaryDefinitionInternalWithSource): d is DictionaryDefinitionInternalWithSource;
|
|
22
|
+
export declare function calcDictionaryDefsToLoad(settings: CSpellSettingsInternal): DictionaryDefinitionInternal[];
|
|
26
23
|
//# sourceMappingURL=DictionarySettings.d.ts.map
|
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.calcDictionaryDefsToLoad = exports.isDictionaryDefinitionWithSource = exports.
|
|
22
|
+
exports.calcDictionaryDefsToLoad = exports.isDictionaryDefinitionWithSource = exports.mapDictDefToInternal = exports.mapDictDefsToInternal = exports.filterDictDefsToLoad = void 0;
|
|
23
23
|
const path = __importStar(require("path"));
|
|
24
24
|
const resolveFile_1 = require("../util/resolveFile");
|
|
25
25
|
const DictionaryReferenceCollection_1 = require("./DictionaryReferenceCollection");
|
|
@@ -56,11 +56,11 @@ function getFullPathName(def) {
|
|
|
56
56
|
}
|
|
57
57
|
return path.join(filePath, file);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return defs === null || defs === void 0 ? void 0 : defs.map((def) =>
|
|
59
|
+
function mapDictDefsToInternal(defs, pathToSettingsFile) {
|
|
60
|
+
return defs === null || defs === void 0 ? void 0 : defs.map((def) => mapDictDefToInternal(def, pathToSettingsFile));
|
|
61
61
|
}
|
|
62
|
-
exports.
|
|
63
|
-
function
|
|
62
|
+
exports.mapDictDefsToInternal = mapDictDefsToInternal;
|
|
63
|
+
function mapDictDefToInternal(def, pathToSettingsFile) {
|
|
64
64
|
const defaultPath = path.dirname(pathToSettingsFile);
|
|
65
65
|
const { path: relPath = '', file = '', ...rest } = def;
|
|
66
66
|
const filePath = path.join(relPath, file);
|
|
@@ -76,10 +76,11 @@ function normalizePathForDictDef(def, pathToSettingsFile) {
|
|
|
76
76
|
...rest,
|
|
77
77
|
name,
|
|
78
78
|
path: r.filename,
|
|
79
|
+
weightMap: undefined,
|
|
79
80
|
__source: pathToSettingsFile,
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
|
-
exports.
|
|
83
|
+
exports.mapDictDefToInternal = mapDictDefToInternal;
|
|
83
84
|
function isDictionaryDefinitionWithSource(d) {
|
|
84
85
|
return d.__source !== undefined;
|
|
85
86
|
}
|
package/dist/Settings/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export { calcOverrideSettings, checkFilenameMatchesGlob, clearCachedSettingsFiles, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getGlobalSettings, getSources, loadConfig, loadPnP, loadPnPSync, mergeInDocSettings, mergeSettings, readRawSettings, readSettings, readSettingsFiles, searchForConfig, sectionCSpell, } from './CSpellSettingsServer';
|
|
2
|
+
export type { ConfigurationDependencies, ImportFileRefWithError } from './CSpellSettingsServer';
|
|
3
|
+
export { getDefaultSettings } from './DefaultSettings';
|
|
4
|
+
export { ImportError } from './ImportError';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|