cspell-lib 6.1.0 → 6.1.3-alpha.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/LanguageIds.js +1 -2
- package/dist/Models/TextDocument.js +3 -3
- package/dist/Settings/CSpellSettingsServer.js +7 -10
- package/dist/Settings/DictionarySettings.js +1 -1
- package/dist/Settings/LanguageSettings.js +1 -2
- package/dist/Settings/configLoader.js +15 -19
- package/dist/Settings/link.js +5 -6
- package/dist/Settings/pnpLoader.js +1 -2
- package/dist/SpellingDictionary/DictionaryLoader.js +2 -2
- package/dist/SpellingDictionary/SpellingDictionaryCollection.js +1 -1
- package/dist/SpellingDictionary/SpellingDictionaryFromTrie.js +3 -4
- package/dist/SpellingDictionary/createSpellingDictionary.js +1 -1
- package/dist/spellCheckFile.js +5 -5
- package/dist/suggestions.js +9 -13
- package/dist/textValidation/determineTextDocumentSettings.js +2 -3
- package/dist/textValidation/docValidator.js +10 -14
- package/dist/textValidation/parsedText.js +1 -2
- package/dist/textValidation/textValidator.js +1 -1
- package/dist/textValidation/validator.js +2 -4
- package/dist/trace.js +15 -19
- package/dist/util/Memorizer.js +2 -4
- package/dist/util/PairingHeap.js +1 -2
- package/dist/util/memorizerWeak.js +2 -4
- package/dist/util/search.js +2 -2
- package/dist/util/text.js +1 -1
- package/dist/util/timer.js +1 -1
- package/dist/util/wordSplitter.js +2 -4
- package/package.json +15 -15
package/dist/LanguageIds.js
CHANGED
|
@@ -241,7 +241,6 @@ function doesSetContainAnyOf(setOfIds, languageId) {
|
|
|
241
241
|
}
|
|
242
242
|
function buildLanguageExtensionMapSet(defs) {
|
|
243
243
|
return defs.reduce((map, def) => {
|
|
244
|
-
var _a;
|
|
245
244
|
function getMapSet(value) {
|
|
246
245
|
const found = map.get(value);
|
|
247
246
|
if (found)
|
|
@@ -254,7 +253,7 @@ function buildLanguageExtensionMapSet(defs) {
|
|
|
254
253
|
getMapSet(value).add(def.id);
|
|
255
254
|
}
|
|
256
255
|
def.extensions.forEach(addId);
|
|
257
|
-
|
|
256
|
+
def.filenames?.forEach(addId);
|
|
258
257
|
return map;
|
|
259
258
|
}, new Map());
|
|
260
259
|
}
|
|
@@ -98,7 +98,7 @@ class TextDocumentImpl {
|
|
|
98
98
|
* @returns this
|
|
99
99
|
*/
|
|
100
100
|
update(edits, version) {
|
|
101
|
-
version = version
|
|
101
|
+
version = version ?? this.version + 1;
|
|
102
102
|
for (const edit of edits) {
|
|
103
103
|
const vsEdit = edit.range
|
|
104
104
|
? {
|
|
@@ -112,9 +112,9 @@ class TextDocumentImpl {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
function createTextDocument({ uri, content, languageId, locale, version, }) {
|
|
115
|
-
version = version
|
|
115
|
+
version = version ?? 1;
|
|
116
116
|
uri = Uri.toUri(uri);
|
|
117
|
-
languageId = languageId
|
|
117
|
+
languageId = languageId ?? (0, LanguageIds_1.getLanguagesForBasename)(Uri.basename(uri));
|
|
118
118
|
languageId = languageId.length === 0 ? 'text' : languageId;
|
|
119
119
|
return new TextDocumentImpl(uri, content, languageId, locale, version);
|
|
120
120
|
}
|
|
@@ -116,7 +116,7 @@ function merge(left, right) {
|
|
|
116
116
|
const leftId = _left.id || _left.languageId || '';
|
|
117
117
|
const rightId = _right.id || _right.languageId || '';
|
|
118
118
|
const includeRegExpList = takeRightOtherwiseLeft(_left.includeRegExpList, _right.includeRegExpList);
|
|
119
|
-
const optionals =
|
|
119
|
+
const optionals = includeRegExpList?.length ? { includeRegExpList } : {};
|
|
120
120
|
const version = max(_left.version, _right.version);
|
|
121
121
|
const settings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({
|
|
122
122
|
..._left,
|
|
@@ -146,6 +146,7 @@ function merge(left, right) {
|
|
|
146
146
|
description: undefined,
|
|
147
147
|
globRoot: undefined,
|
|
148
148
|
import: undefined,
|
|
149
|
+
plugins: mergeList(_left.plugins, _right.plugins),
|
|
149
150
|
__imports: mergeImportRefs(_left, _right),
|
|
150
151
|
__importRef: undefined,
|
|
151
152
|
});
|
|
@@ -176,8 +177,7 @@ function doesLeftHaveRightAncestor(left, right) {
|
|
|
176
177
|
return hasAncestor(left, right, 1);
|
|
177
178
|
}
|
|
178
179
|
function hasAncestor(s, ancestor, side) {
|
|
179
|
-
|
|
180
|
-
const sources = (_a = s.source) === null || _a === void 0 ? void 0 : _a.sources;
|
|
180
|
+
const sources = s.source?.sources;
|
|
181
181
|
if (!sources)
|
|
182
182
|
return false;
|
|
183
183
|
// calc the first or last index of the source array.
|
|
@@ -194,7 +194,7 @@ function mergeInDocSettings(left, right) {
|
|
|
194
194
|
}
|
|
195
195
|
exports.mergeInDocSettings = mergeInDocSettings;
|
|
196
196
|
function takeRightOtherwiseLeft(left, right) {
|
|
197
|
-
if (right
|
|
197
|
+
if (right?.length) {
|
|
198
198
|
return right;
|
|
199
199
|
}
|
|
200
200
|
return left || right;
|
|
@@ -230,13 +230,12 @@ function _finalizeSettings(settings) {
|
|
|
230
230
|
return finalized;
|
|
231
231
|
}
|
|
232
232
|
function toInternalSettings(settings) {
|
|
233
|
-
var _a;
|
|
234
233
|
if (settings === undefined)
|
|
235
234
|
return undefined;
|
|
236
235
|
if ((0, CSpellSettingsInternalDef_1.isCSpellSettingsInternal)(settings))
|
|
237
236
|
return settings;
|
|
238
237
|
const { dictionaryDefinitions: defs, ...rest } = settings;
|
|
239
|
-
const dictionaryDefinitions = (0, DictionarySettings_1.mapDictDefsToInternal)(defs, filenameToDirectory(
|
|
238
|
+
const dictionaryDefinitions = (0, DictionarySettings_1.mapDictDefsToInternal)(defs, filenameToDirectory(settings.source?.filename) || resolveCwd());
|
|
240
239
|
const setting = dictionaryDefinitions ? { ...rest, dictionaryDefinitions } : rest;
|
|
241
240
|
return (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)(setting);
|
|
242
241
|
}
|
|
@@ -279,11 +278,10 @@ function getSources(settings) {
|
|
|
279
278
|
const visited = new Set();
|
|
280
279
|
const sources = [];
|
|
281
280
|
function _walkSourcesTree(settings) {
|
|
282
|
-
var _a, _b;
|
|
283
281
|
if (!settings || visited.has(settings))
|
|
284
282
|
return;
|
|
285
283
|
visited.add(settings);
|
|
286
|
-
if (!
|
|
284
|
+
if (!settings.source?.sources?.length) {
|
|
287
285
|
sources.push(settings);
|
|
288
286
|
return;
|
|
289
287
|
}
|
|
@@ -294,7 +292,6 @@ function getSources(settings) {
|
|
|
294
292
|
}
|
|
295
293
|
exports.getSources = getSources;
|
|
296
294
|
function mergeImportRefs(left, right = {}) {
|
|
297
|
-
var _a;
|
|
298
295
|
const imports = new Map(left.__imports || []);
|
|
299
296
|
if (left.__importRef) {
|
|
300
297
|
imports.set(left.__importRef.filename, left.__importRef);
|
|
@@ -302,7 +299,7 @@ function mergeImportRefs(left, right = {}) {
|
|
|
302
299
|
if (right.__importRef) {
|
|
303
300
|
imports.set(right.__importRef.filename, right.__importRef);
|
|
304
301
|
}
|
|
305
|
-
const rightImports =
|
|
302
|
+
const rightImports = right.__imports?.values() || [];
|
|
306
303
|
for (const ref of rightImports) {
|
|
307
304
|
imports.set(ref.filename, ref);
|
|
308
305
|
}
|
|
@@ -59,7 +59,7 @@ function fixPath(def) {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
function mapDictDefsToInternal(defs, pathToSettingsFile) {
|
|
62
|
-
return defs
|
|
62
|
+
return defs?.map((def) => mapDictDefToInternal(def, pathToSettingsFile));
|
|
63
63
|
}
|
|
64
64
|
exports.mapDictDefsToInternal = mapDictDefsToInternal;
|
|
65
65
|
function mapDictDefToInternal(def, pathToSettingsFile) {
|
|
@@ -85,8 +85,7 @@ function calcSettingsForLanguage(languageSettings, languageId, locale) {
|
|
|
85
85
|
exports.calcSettingsForLanguage = calcSettingsForLanguage;
|
|
86
86
|
const cacheDoesLanguageSettingMatchLanguageId = new WeakMap();
|
|
87
87
|
function doesLanguageSettingMatchLanguageId(s, languageId) {
|
|
88
|
-
|
|
89
|
-
const r = (_a = cacheDoesLanguageSettingMatchLanguageId.get(s)) !== null && _a !== void 0 ? _a : new Map();
|
|
88
|
+
const r = cacheDoesLanguageSettingMatchLanguageId.get(s) ?? new Map();
|
|
90
89
|
const f = r.get(languageId);
|
|
91
90
|
if (f !== undefined) {
|
|
92
91
|
return f;
|
|
@@ -105,7 +105,7 @@ function readConfig(fileRef) {
|
|
|
105
105
|
const s = {};
|
|
106
106
|
try {
|
|
107
107
|
const r = cspellConfigExplorerSync.load(filename);
|
|
108
|
-
if (!
|
|
108
|
+
if (!r?.config)
|
|
109
109
|
throw new Error(`not found: "${filename}"`);
|
|
110
110
|
Object.assign(s, r.config);
|
|
111
111
|
normalizeRawConfig(s);
|
|
@@ -190,7 +190,7 @@ function mergeSourceList(orig, append) {
|
|
|
190
190
|
return [...collection.values()];
|
|
191
191
|
}
|
|
192
192
|
function importSettings(fileRef, defaultValues, pnpSettings) {
|
|
193
|
-
defaultValues = defaultValues
|
|
193
|
+
defaultValues = defaultValues ?? defaultSettings;
|
|
194
194
|
let { filename } = fileRef;
|
|
195
195
|
filename = path.resolve(filename);
|
|
196
196
|
const importRef = { ...fileRef, filename };
|
|
@@ -230,10 +230,9 @@ async function normalizeSearchForConfigResultAsync(searchPath, searchResult, pnp
|
|
|
230
230
|
return normalizeSearchForConfigResult(searchPath, result, pnpSettings);
|
|
231
231
|
}
|
|
232
232
|
function normalizeSearchForConfigResult(searchPath, searchResult, pnpSettings) {
|
|
233
|
-
var _a;
|
|
234
233
|
const error = searchResult instanceof ImportError_1.ImportError ? searchResult : undefined;
|
|
235
234
|
const result = searchResult instanceof ImportError_1.ImportError ? undefined : searchResult;
|
|
236
|
-
const filepath = result
|
|
235
|
+
const filepath = result?.filepath;
|
|
237
236
|
if (filepath) {
|
|
238
237
|
const cached = cachedFiles.get(filepath);
|
|
239
238
|
if (cached) {
|
|
@@ -245,10 +244,10 @@ function normalizeSearchForConfigResult(searchPath, searchResult, pnpSettings) {
|
|
|
245
244
|
}
|
|
246
245
|
}
|
|
247
246
|
const { config = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({}) } = result || {};
|
|
248
|
-
const filename =
|
|
247
|
+
const filename = result?.filepath ?? searchPath;
|
|
249
248
|
const importRef = { filename: filename, error };
|
|
250
249
|
const id = [path.basename(path.dirname(filename)), path.basename(filename)].join('/');
|
|
251
|
-
const name =
|
|
250
|
+
const name = result?.filepath ? id : `Config not found: ${id}`;
|
|
252
251
|
const finalizeSettings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({ id, name, __importRef: importRef });
|
|
253
252
|
const settings = { id, ...config };
|
|
254
253
|
cachedFiles.set(filename, finalizeSettings); // add an empty entry to prevent circular references.
|
|
@@ -371,7 +370,6 @@ function clearCachedSettingsFiles() {
|
|
|
371
370
|
}
|
|
372
371
|
exports.clearCachedSettingsFiles = clearCachedSettingsFiles;
|
|
373
372
|
function mergeImportRefs(left, right = {}) {
|
|
374
|
-
var _a;
|
|
375
373
|
const imports = new Map(left.__imports || []);
|
|
376
374
|
if (left.__importRef) {
|
|
377
375
|
imports.set(left.__importRef.filename, left.__importRef);
|
|
@@ -379,7 +377,7 @@ function mergeImportRefs(left, right = {}) {
|
|
|
379
377
|
if (right.__importRef) {
|
|
380
378
|
imports.set(right.__importRef.filename, right.__importRef);
|
|
381
379
|
}
|
|
382
|
-
const rightImports =
|
|
380
|
+
const rightImports = right.__imports?.values() || [];
|
|
383
381
|
for (const ref of rightImports) {
|
|
384
382
|
imports.set(ref.filename, ref);
|
|
385
383
|
}
|
|
@@ -394,17 +392,17 @@ function extractImportErrors(settings) {
|
|
|
394
392
|
}
|
|
395
393
|
exports.extractImportErrors = extractImportErrors;
|
|
396
394
|
function resolveGlobRoot(settings, pathToSettingsFile) {
|
|
397
|
-
var _a;
|
|
398
395
|
const settingsFileDirRaw = path.dirname(pathToSettingsFile);
|
|
399
396
|
const isVSCode = path.basename(settingsFileDirRaw) === '.vscode';
|
|
400
397
|
const settingsFileDir = isVSCode ? path.dirname(settingsFileDirRaw) : settingsFileDirRaw;
|
|
401
398
|
const envGlobRoot = process.env[CSpellSettingsServer_1.ENV_CSPELL_GLOB_ROOT];
|
|
402
|
-
const defaultGlobRoot = envGlobRoot
|
|
403
|
-
const rawRoot =
|
|
404
|
-
(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
399
|
+
const defaultGlobRoot = envGlobRoot ?? '${cwd}';
|
|
400
|
+
const rawRoot = settings.globRoot ??
|
|
401
|
+
(settings.version === CSpellSettingsServer_1.configSettingsFileVersion0_1 ||
|
|
402
|
+
(envGlobRoot && !settings.version) ||
|
|
403
|
+
(isVSCode && !settings.version)
|
|
404
|
+
? defaultGlobRoot
|
|
405
|
+
: settingsFileDir);
|
|
408
406
|
const globRoot = rawRoot.startsWith('${cwd}') ? rawRoot : path.resolve(settingsFileDir, rawRoot);
|
|
409
407
|
return globRoot;
|
|
410
408
|
}
|
|
@@ -431,9 +429,8 @@ function toGlobDef(g, root, source) {
|
|
|
431
429
|
return g;
|
|
432
430
|
}
|
|
433
431
|
function normalizeDictionaryDefs(settings, pathToSettingsFile) {
|
|
434
|
-
var _a;
|
|
435
432
|
const dictionaryDefinitions = (0, DictionarySettings_1.mapDictDefsToInternal)(settings.dictionaryDefinitions, pathToSettingsFile);
|
|
436
|
-
const languageSettings =
|
|
433
|
+
const languageSettings = settings.languageSettings?.map((langSetting) => util.clean({
|
|
437
434
|
...langSetting,
|
|
438
435
|
dictionaryDefinitions: (0, DictionarySettings_1.mapDictDefsToInternal)(langSetting.dictionaryDefinitions, pathToSettingsFile),
|
|
439
436
|
}));
|
|
@@ -443,9 +440,8 @@ function normalizeDictionaryDefs(settings, pathToSettingsFile) {
|
|
|
443
440
|
});
|
|
444
441
|
}
|
|
445
442
|
function normalizeOverrides(settings, pathToSettingsFile) {
|
|
446
|
-
var _a;
|
|
447
443
|
const { globRoot = path.dirname(pathToSettingsFile) } = settings;
|
|
448
|
-
const overrides =
|
|
444
|
+
const overrides = settings.overrides?.map((override) => {
|
|
449
445
|
const filename = toGlobDef(override.filename, globRoot, pathToSettingsFile);
|
|
450
446
|
const { dictionaryDefinitions, languageSettings } = normalizeDictionaryDefs(override, pathToSettingsFile);
|
|
451
447
|
return util.clean({
|
package/dist/Settings/link.js
CHANGED
|
@@ -72,7 +72,7 @@ function addPathsToGlobalImports(paths) {
|
|
|
72
72
|
const error = (0, GlobalSettings_1.writeRawGlobalSettings)(globalSettings);
|
|
73
73
|
return {
|
|
74
74
|
success: !error,
|
|
75
|
-
error: error
|
|
75
|
+
error: error?.message,
|
|
76
76
|
resolvedSettings,
|
|
77
77
|
};
|
|
78
78
|
}
|
|
@@ -88,7 +88,7 @@ function removePathsFromGlobalImports(paths) {
|
|
|
88
88
|
const listResult = listGlobalImports();
|
|
89
89
|
const toRemove = new Set();
|
|
90
90
|
function matchPackage(pathToRemove) {
|
|
91
|
-
return ({ package: pkg, id }) => pathToRemove ===
|
|
91
|
+
return ({ package: pkg, id }) => pathToRemove === pkg?.name || pathToRemove === id;
|
|
92
92
|
}
|
|
93
93
|
function compareFilenames(fullPath, partialPath) {
|
|
94
94
|
if (fullPath === partialPath)
|
|
@@ -124,16 +124,15 @@ function removePathsFromGlobalImports(paths) {
|
|
|
124
124
|
return {
|
|
125
125
|
success: true,
|
|
126
126
|
removed: [...toRemove],
|
|
127
|
-
error: error
|
|
127
|
+
error: error?.toString(),
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
exports.removePathsFromGlobalImports = removePathsFromGlobalImports;
|
|
131
131
|
function resolveSettings(filename) {
|
|
132
|
-
var _a;
|
|
133
132
|
const settings = (0, configLoader_1.readRawSettings)(filename);
|
|
134
133
|
const ref = settings.__importRef;
|
|
135
|
-
const resolvedToFilename = ref
|
|
136
|
-
const error =
|
|
134
|
+
const resolvedToFilename = ref?.filename;
|
|
135
|
+
const error = ref?.error?.message || (!resolvedToFilename && 'File not Found') || undefined;
|
|
137
136
|
return (0, util_1.clean)({
|
|
138
137
|
filename,
|
|
139
138
|
resolvedToFilename,
|
|
@@ -40,10 +40,9 @@ class PnpLoader {
|
|
|
40
40
|
return result;
|
|
41
41
|
}
|
|
42
42
|
async peek(uriDirectory) {
|
|
43
|
-
var _a;
|
|
44
43
|
await lock;
|
|
45
44
|
const cacheKey = this.calcKey(uriDirectory);
|
|
46
|
-
return
|
|
45
|
+
return cachedRequests.get(cacheKey) ?? Promise.resolve(undefined);
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
48
|
* Request that the nearest .pnp file gets loaded
|
|
@@ -89,7 +89,7 @@ function loadDictionary(def) {
|
|
|
89
89
|
exports.loadDictionary = loadDictionary;
|
|
90
90
|
function loadDictionarySync(def) {
|
|
91
91
|
const { key, entry } = getCacheEntry(def);
|
|
92
|
-
if (
|
|
92
|
+
if (entry?.dictionary && entry.loadingState === LoadingState.Loaded) {
|
|
93
93
|
return entry.dictionary;
|
|
94
94
|
}
|
|
95
95
|
const loadedEntry = loadEntrySync(def.path, def);
|
|
@@ -101,7 +101,7 @@ const importantOptionKeys = ['name', 'noSuggest', 'useCompounds', 'type'];
|
|
|
101
101
|
function calcKey(def) {
|
|
102
102
|
const path = def.path;
|
|
103
103
|
const loaderType = determineType(path, def);
|
|
104
|
-
const optValues = importantOptionKeys.map((k) =>
|
|
104
|
+
const optValues = importantOptionKeys.map((k) => def[k]?.toString() || '');
|
|
105
105
|
const parts = [path, loaderType].concat(optValues);
|
|
106
106
|
return parts.join('|');
|
|
107
107
|
}
|
|
@@ -82,7 +82,7 @@ class SpellingDictionaryCollection {
|
|
|
82
82
|
this.dictionaries.forEach((dict) => dict.genSuggestions(collector, _suggestOptions));
|
|
83
83
|
}
|
|
84
84
|
getErrors() {
|
|
85
|
-
return this.dictionaries.reduce((errors, dict) =>
|
|
85
|
+
return this.dictionaries.reduce((errors, dict) => errors.concat(dict.getErrors?.() || []), []);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
exports.SpellingDictionaryCollection = SpellingDictionaryCollection;
|
|
@@ -9,7 +9,6 @@ const util_1 = require("../util/util");
|
|
|
9
9
|
const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods");
|
|
10
10
|
class SpellingDictionaryFromTrie {
|
|
11
11
|
constructor(trie, name, options, source = 'from trie', size) {
|
|
12
|
-
var _a;
|
|
13
12
|
this.trie = trie;
|
|
14
13
|
this.name = name;
|
|
15
14
|
this.options = options;
|
|
@@ -20,7 +19,7 @@ class SpellingDictionaryFromTrie {
|
|
|
20
19
|
this.type = 'SpellingDictionaryFromTrie';
|
|
21
20
|
this._find = (0, Memorizer_1.memorizer)((word, useCompounds, ignoreCase) => this.findAnyForm(word, useCompounds, ignoreCase), SpellingDictionaryFromTrie.cachedWordsLimit);
|
|
22
21
|
this.mapWord = (0, repMap_1.createMapper)(options.repMap || []);
|
|
23
|
-
this.isDictionaryCaseSensitive =
|
|
22
|
+
this.isDictionaryCaseSensitive = options.caseSensitive ?? !trie.isLegacy;
|
|
24
23
|
this.containsNoSuggestWords = options.noSuggest || false;
|
|
25
24
|
this._size = size || 0;
|
|
26
25
|
this.weightMap = options.weightMap || (0, SpellingDictionaryMethods_1.createWeightMapFromDictionaryInformation)(options.dictionaryInformation);
|
|
@@ -114,10 +113,10 @@ class SpellingDictionaryFromTrie {
|
|
|
114
113
|
return collector.suggestions.map((r) => ({ ...r, word: r.word }));
|
|
115
114
|
}
|
|
116
115
|
genSuggestions(collector, suggestOptions) {
|
|
117
|
-
var _a;
|
|
118
116
|
if (this.options.noSuggest)
|
|
119
117
|
return;
|
|
120
|
-
const _compoundMethod =
|
|
118
|
+
const _compoundMethod = suggestOptions.compoundMethod ??
|
|
119
|
+
(this.options.useCompounds ? cspell_trie_lib_1.CompoundWordsMethod.JOIN_WORDS : cspell_trie_lib_1.CompoundWordsMethod.NONE);
|
|
121
120
|
(0, SpellingDictionaryMethods_1.wordSuggestFormsArray)(collector.word).forEach((w) => this.trie.genSuggestions((0, SpellingDictionaryMethods_1.impersonateCollector)(collector, w), _compoundMethod));
|
|
122
121
|
}
|
|
123
122
|
getErrors() {
|
|
@@ -45,7 +45,7 @@ function _createSpellingDictionary(params) {
|
|
|
45
45
|
function createForbiddenWordsDictionary(wordList, name, source, options) {
|
|
46
46
|
// console.log(`createSpellingDictionary ${name} ${source}`);
|
|
47
47
|
const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList.concat(wordList.map((a) => a.toLowerCase())), {
|
|
48
|
-
stripCaseAndAccents: !
|
|
48
|
+
stripCaseAndAccents: !options?.noSuggest,
|
|
49
49
|
});
|
|
50
50
|
const forbidWords = gensequence_1.operators.map((w) => '!' + w)(words);
|
|
51
51
|
const trie = (0, cspell_trie_lib_1.buildTrieFast)(forbidWords);
|
package/dist/spellCheckFile.js
CHANGED
|
@@ -59,8 +59,8 @@ async function spellCheckDocument(document, options, settings) {
|
|
|
59
59
|
}
|
|
60
60
|
exports.spellCheckDocument = spellCheckDocument;
|
|
61
61
|
async function spellCheckFullDocument(document, options, settings) {
|
|
62
|
-
const { uri, text: content } = document;
|
|
63
|
-
const doc = (0, TextDocument_1.createTextDocument)({ uri, content });
|
|
62
|
+
const { uri, text: content, languageId, locale } = document;
|
|
63
|
+
const doc = (0, TextDocument_1.createTextDocument)({ uri, content, languageId, locale });
|
|
64
64
|
const docValOptions = options;
|
|
65
65
|
const docValidator = new textValidation_1.DocumentValidator(doc, docValOptions, settings);
|
|
66
66
|
await docValidator.prepare();
|
|
@@ -69,8 +69,8 @@ async function spellCheckFullDocument(document, options, settings) {
|
|
|
69
69
|
return {
|
|
70
70
|
document,
|
|
71
71
|
options,
|
|
72
|
-
settingsUsed:
|
|
73
|
-
localConfigFilepath: prep
|
|
72
|
+
settingsUsed: prep?.localConfig || settings,
|
|
73
|
+
localConfigFilepath: prep?.localConfigFilepath,
|
|
74
74
|
issues: [],
|
|
75
75
|
checked: false,
|
|
76
76
|
errors: docValidator.errors,
|
|
@@ -81,7 +81,7 @@ async function spellCheckFullDocument(document, options, settings) {
|
|
|
81
81
|
document,
|
|
82
82
|
options,
|
|
83
83
|
settingsUsed: docValidator.getFinalizedDocSettings(),
|
|
84
|
-
localConfigFilepath: prep
|
|
84
|
+
localConfigFilepath: prep?.localConfigFilepath,
|
|
85
85
|
issues,
|
|
86
86
|
checked: docValidator.shouldCheckDocument(),
|
|
87
87
|
errors: undefined,
|
package/dist/suggestions.js
CHANGED
|
@@ -35,21 +35,19 @@ async function* suggestionsForWords(words, options, settings = {}) {
|
|
|
35
35
|
}
|
|
36
36
|
exports.suggestionsForWords = suggestionsForWords;
|
|
37
37
|
async function suggestionsForWord(word, options, settings = {}) {
|
|
38
|
-
var _a;
|
|
39
38
|
const { languageId, locale: language, strict = true, numChanges = 4, numSuggestions = 8, includeTies = true, includeDefaultConfig = true, dictionaries, } = options || {};
|
|
40
39
|
const ignoreCase = !strict;
|
|
41
40
|
async function determineDictionaries(config) {
|
|
42
|
-
var _a, _b;
|
|
43
41
|
const withLocale = (0, Settings_1.mergeSettings)(config, util.clean({
|
|
44
42
|
language: language || config.language,
|
|
45
43
|
// dictionaries: dictionaries?.length ? dictionaries : config.dictionaries,
|
|
46
44
|
}));
|
|
47
|
-
const withLanguageId = (0, LanguageSettings_1.calcSettingsForLanguageId)(withLocale,
|
|
45
|
+
const withLanguageId = (0, LanguageSettings_1.calcSettingsForLanguageId)(withLocale, languageId ?? withLocale.languageId ?? 'plaintext');
|
|
48
46
|
const settings = (0, Settings_1.finalizeSettings)(withLanguageId);
|
|
49
|
-
settings.dictionaries =
|
|
47
|
+
settings.dictionaries = dictionaries?.length ? dictionaries : settings.dictionaries || [];
|
|
50
48
|
validateDictionaries(settings, dictionaries);
|
|
51
49
|
const dictionaryCollection = await (0, SpellingDictionary_1.getDictionaryInternal)(settings);
|
|
52
|
-
settings.dictionaries =
|
|
50
|
+
settings.dictionaries = settings.dictionaryDefinitions?.map((def) => def.name) || [];
|
|
53
51
|
const allDictionaryCollection = await (0, SpellingDictionary_1.getDictionaryInternal)(settings);
|
|
54
52
|
return {
|
|
55
53
|
dictionaryCollection,
|
|
@@ -58,7 +56,7 @@ async function suggestionsForWord(word, options, settings = {}) {
|
|
|
58
56
|
}
|
|
59
57
|
await (0, SpellingDictionary_1.refreshDictionaryCache)();
|
|
60
58
|
const config = includeDefaultConfig
|
|
61
|
-
? (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)(
|
|
59
|
+
? (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)(settings.loadDefaultConfiguration ?? true), (0, Settings_1.getGlobalSettings)(), settings)
|
|
62
60
|
: settings;
|
|
63
61
|
const { dictionaryCollection, allDictionaryCollection } = await determineDictionaries(config);
|
|
64
62
|
const opts = { ignoreCase, numChanges, numSuggestions, includeTies };
|
|
@@ -69,8 +67,8 @@ async function suggestionsForWord(word, options, settings = {}) {
|
|
|
69
67
|
const found = allDictionaryCollection.find(sug.word, findOpts);
|
|
70
68
|
return {
|
|
71
69
|
...sug,
|
|
72
|
-
forbidden:
|
|
73
|
-
noSuggest:
|
|
70
|
+
forbidden: found?.forbidden || false,
|
|
71
|
+
noSuggest: found?.noSuggest || false,
|
|
74
72
|
};
|
|
75
73
|
});
|
|
76
74
|
return {
|
|
@@ -92,8 +90,7 @@ function combine(suggestions) {
|
|
|
92
90
|
return [...words.values()];
|
|
93
91
|
}
|
|
94
92
|
function limitResults(suggestions, numSuggestions, includeTies) {
|
|
95
|
-
|
|
96
|
-
let cost = (_a = suggestions[0]) === null || _a === void 0 ? void 0 : _a.cost;
|
|
93
|
+
let cost = suggestions[0]?.cost;
|
|
97
94
|
let i = 0;
|
|
98
95
|
for (; i < suggestions.length; ++i) {
|
|
99
96
|
if (i >= numSuggestions && (!includeTies || suggestions[i].cost > cost)) {
|
|
@@ -104,10 +101,9 @@ function limitResults(suggestions, numSuggestions, includeTies) {
|
|
|
104
101
|
return suggestions.slice(0, i);
|
|
105
102
|
}
|
|
106
103
|
function validateDictionaries(settings, dictionaries) {
|
|
107
|
-
|
|
108
|
-
if (!(dictionaries === null || dictionaries === void 0 ? void 0 : dictionaries.length))
|
|
104
|
+
if (!dictionaries?.length)
|
|
109
105
|
return;
|
|
110
|
-
const knownDicts = new Set(
|
|
106
|
+
const knownDicts = new Set(settings.dictionaryDefinitions?.map((def) => def.name) || []);
|
|
111
107
|
for (const dict of dictionaries) {
|
|
112
108
|
if (!knownDicts.has(dict)) {
|
|
113
109
|
throw new SuggestionError(`Unknown dictionary: "${dict}"`, 'E_dictionary_unknown');
|
|
@@ -41,11 +41,10 @@ const TextDocumentSettings_1 = require("../Settings/TextDocumentSettings");
|
|
|
41
41
|
* @param settings - The near final settings. Should already be the combination of all configuration files.
|
|
42
42
|
*/
|
|
43
43
|
function determineTextDocumentSettings(doc, settings) {
|
|
44
|
-
var _a, _b;
|
|
45
44
|
const filename = doc.uri.fsPath;
|
|
46
|
-
const settingsWithDefaults = (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)(
|
|
45
|
+
const settingsWithDefaults = (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)(settings.loadDefaultConfiguration ?? true), (0, Settings_1.getGlobalSettings)(), settings);
|
|
47
46
|
const fileSettings = (0, Settings_1.calcOverrideSettings)(settingsWithDefaults, filename);
|
|
48
|
-
const languageIds =
|
|
47
|
+
const languageIds = fileSettings?.languageId?.length
|
|
49
48
|
? fileSettings.languageId
|
|
50
49
|
: doc.languageId
|
|
51
50
|
? doc.languageId
|
|
@@ -39,7 +39,6 @@ class DocumentValidator {
|
|
|
39
39
|
return this._ready;
|
|
40
40
|
}
|
|
41
41
|
prepareSync() {
|
|
42
|
-
var _a, _b, _c;
|
|
43
42
|
// @todo
|
|
44
43
|
// Determine doc settings.
|
|
45
44
|
// Calc include ranges
|
|
@@ -55,13 +54,13 @@ class DocumentValidator {
|
|
|
55
54
|
: useSearchForConfig
|
|
56
55
|
? this.errorCatcherWrapper(() => searchForDocumentConfigSync(this._document, settings, settings))
|
|
57
56
|
: undefined;
|
|
58
|
-
this.addPossibleError(
|
|
57
|
+
this.addPossibleError(localConfig?.__importRef?.error);
|
|
59
58
|
const config = (0, Settings_1.mergeSettings)(settings, localConfig);
|
|
60
59
|
const docSettings = (0, determineTextDocumentSettings_1.determineTextDocumentSettings)(this._document, config);
|
|
61
60
|
const dict = (0, SpellingDictionary_1.getDictionaryInternalSync)(docSettings);
|
|
62
|
-
const matcher = new cspell_glob_1.GlobMatcher(
|
|
61
|
+
const matcher = new cspell_glob_1.GlobMatcher(localConfig?.ignorePaths || [], { root: process.cwd(), dot: true });
|
|
63
62
|
const uri = this._document.uri;
|
|
64
|
-
const shouldCheck = !matcher.match(uri.fsPath) && (
|
|
63
|
+
const shouldCheck = !matcher.match(uri.fsPath) && (docSettings.enabled ?? true);
|
|
65
64
|
const finalSettings = (0, Settings_1.finalizeSettings)(docSettings);
|
|
66
65
|
const validateOptions = (0, validator_1.settingsToValidateOptions)(finalSettings);
|
|
67
66
|
const includeRanges = (0, textValidator_1.calcTextInclusionRanges)(this._document.text, validateOptions);
|
|
@@ -77,7 +76,7 @@ class DocumentValidator {
|
|
|
77
76
|
segmenter,
|
|
78
77
|
lineValidator,
|
|
79
78
|
localConfig,
|
|
80
|
-
localConfigFilepath:
|
|
79
|
+
localConfigFilepath: localConfig?.__importRef?.filename,
|
|
81
80
|
};
|
|
82
81
|
this._ready = true;
|
|
83
82
|
this._preparationTime = timer.elapsed();
|
|
@@ -92,7 +91,6 @@ class DocumentValidator {
|
|
|
92
91
|
return this._prepared;
|
|
93
92
|
}
|
|
94
93
|
async _prepareAsync() {
|
|
95
|
-
var _a, _b, _c;
|
|
96
94
|
(0, assert_1.default)(!this._ready);
|
|
97
95
|
const timer = (0, timer_1.createTimer)();
|
|
98
96
|
const { options, settings } = this;
|
|
@@ -103,13 +101,13 @@ class DocumentValidator {
|
|
|
103
101
|
? this.catchError(searchForDocumentConfig(this._document, settings, settings))
|
|
104
102
|
: undefined;
|
|
105
103
|
const localConfig = (await pLocalConfig) || {};
|
|
106
|
-
this.addPossibleError(
|
|
104
|
+
this.addPossibleError(localConfig?.__importRef?.error);
|
|
107
105
|
const config = (0, Settings_1.mergeSettings)(settings, localConfig);
|
|
108
106
|
const docSettings = (0, determineTextDocumentSettings_1.determineTextDocumentSettings)(this._document, config);
|
|
109
107
|
const dict = await (0, SpellingDictionary_1.getDictionaryInternal)(docSettings);
|
|
110
|
-
const matcher = new cspell_glob_1.GlobMatcher(
|
|
108
|
+
const matcher = new cspell_glob_1.GlobMatcher(localConfig?.ignorePaths || [], { root: process.cwd(), dot: true });
|
|
111
109
|
const uri = this._document.uri;
|
|
112
|
-
const shouldCheck = !matcher.match(uri.fsPath) && (
|
|
110
|
+
const shouldCheck = !matcher.match(uri.fsPath) && (docSettings.enabled ?? true);
|
|
113
111
|
const finalSettings = (0, Settings_1.finalizeSettings)(docSettings);
|
|
114
112
|
const validateOptions = (0, validator_1.settingsToValidateOptions)(finalSettings);
|
|
115
113
|
const includeRanges = (0, textValidator_1.calcTextInclusionRanges)(this._document.text, validateOptions);
|
|
@@ -125,19 +123,18 @@ class DocumentValidator {
|
|
|
125
123
|
segmenter,
|
|
126
124
|
lineValidator,
|
|
127
125
|
localConfig,
|
|
128
|
-
localConfigFilepath:
|
|
126
|
+
localConfigFilepath: localConfig?.__importRef?.filename,
|
|
129
127
|
};
|
|
130
128
|
this._ready = true;
|
|
131
129
|
this._preparationTime = timer.elapsed();
|
|
132
130
|
}
|
|
133
131
|
_updatePrep() {
|
|
134
|
-
var _a;
|
|
135
132
|
(0, assert_1.default)(this._preparations, ERROR_NOT_PREPARED);
|
|
136
133
|
const timer = (0, timer_1.createTimer)();
|
|
137
134
|
const prep = this._preparations;
|
|
138
135
|
const docSettings = (0, determineTextDocumentSettings_1.determineTextDocumentSettings)(this._document, prep.config);
|
|
139
136
|
const dict = (0, SpellingDictionary_1.getDictionaryInternalSync)(docSettings);
|
|
140
|
-
const shouldCheck =
|
|
137
|
+
const shouldCheck = docSettings.enabled ?? true;
|
|
141
138
|
const finalSettings = (0, Settings_1.finalizeSettings)(docSettings);
|
|
142
139
|
const validateOptions = (0, validator_1.settingsToValidateOptions)(finalSettings);
|
|
143
140
|
const includeRanges = (0, textValidator_1.calcTextInclusionRanges)(this._document.text, validateOptions);
|
|
@@ -251,7 +248,6 @@ class DocumentValidator {
|
|
|
251
248
|
return this._suggestions.get(text);
|
|
252
249
|
}
|
|
253
250
|
genSuggestions(text) {
|
|
254
|
-
var _a;
|
|
255
251
|
(0, assert_1.default)(this._preparations, ERROR_NOT_PREPARED);
|
|
256
252
|
const settings = this._preparations.docSettings;
|
|
257
253
|
const dict = this._preparations.dictionary;
|
|
@@ -259,7 +255,7 @@ class DocumentValidator {
|
|
|
259
255
|
compoundMethod: 0,
|
|
260
256
|
numSuggestions: this.options.numSuggestions,
|
|
261
257
|
includeTies: false,
|
|
262
|
-
ignoreCase: !(
|
|
258
|
+
ignoreCase: !(settings.caseSensitive ?? false),
|
|
263
259
|
timeout: settings.suggestionsTimeout,
|
|
264
260
|
numChanges: settings.suggestionNumChanges,
|
|
265
261
|
});
|
|
@@ -12,11 +12,10 @@ function mapIssueBackToOriginalPos(parsedText, issue) {
|
|
|
12
12
|
}
|
|
13
13
|
exports.mapIssueBackToOriginalPos = mapIssueBackToOriginalPos;
|
|
14
14
|
function mapTextOffsetBackToOriginalPos(parsedText, textOff) {
|
|
15
|
-
var _a;
|
|
16
15
|
if (!parsedText.map || !parsedText.map.length)
|
|
17
16
|
return textOff;
|
|
18
17
|
const off = textOff.offset - parsedText.range[0];
|
|
19
|
-
const range = mapRangeBackToOriginalPos([off, off + (
|
|
18
|
+
const range = mapRangeBackToOriginalPos([off, off + (textOff.length ?? textOff.text.length)], parsedText.map);
|
|
20
19
|
return {
|
|
21
20
|
text: textOff.text,
|
|
22
21
|
offset: parsedText.range[0] + range[0],
|
|
@@ -188,7 +188,7 @@ function mapLineSegmentAgainstRangesFactory(includeRanges) {
|
|
|
188
188
|
const parts = [];
|
|
189
189
|
const { segment, line } = lineSeg;
|
|
190
190
|
const { text, offset, length } = segment;
|
|
191
|
-
const textEndPos = offset + (length
|
|
191
|
+
const textEndPos = offset + (length ?? text.length);
|
|
192
192
|
let textStartPos = offset;
|
|
193
193
|
while (rangePos && (rangePos >= includeRanges.length || includeRanges[rangePos].startPos > textStartPos)) {
|
|
194
194
|
rangePos -= 1;
|
|
@@ -31,7 +31,6 @@ const util_1 = require("../util/util");
|
|
|
31
31
|
const textValidator_1 = require("./textValidator");
|
|
32
32
|
exports.diagSource = 'cSpell Checker';
|
|
33
33
|
async function validateText(text, settings, options = {}) {
|
|
34
|
-
var _a;
|
|
35
34
|
const finalSettings = Settings.finalizeSettings(settings);
|
|
36
35
|
const dict = await (0, SpellingDictionary_1.getDictionaryInternal)(finalSettings);
|
|
37
36
|
const issues = [...(0, textValidator_1.validateText)(text, dict, settingsToValidateOptions(finalSettings))];
|
|
@@ -42,7 +41,7 @@ async function validateText(text, settings, options = {}) {
|
|
|
42
41
|
numSuggestions: options.numSuggestions,
|
|
43
42
|
compoundMethod: SpellingDictionary_1.CompoundWordsMethod.NONE,
|
|
44
43
|
includeTies: false,
|
|
45
|
-
ignoreCase: !(
|
|
44
|
+
ignoreCase: !(settings.caseSensitive ?? false),
|
|
46
45
|
timeout: settings.suggestionsTimeout,
|
|
47
46
|
numChanges: settings.suggestionNumChanges,
|
|
48
47
|
});
|
|
@@ -56,10 +55,9 @@ async function validateText(text, settings, options = {}) {
|
|
|
56
55
|
}
|
|
57
56
|
exports.validateText = validateText;
|
|
58
57
|
function settingsToValidateOptions(settings) {
|
|
59
|
-
var _a;
|
|
60
58
|
const opt = {
|
|
61
59
|
...settings,
|
|
62
|
-
ignoreCase: !(
|
|
60
|
+
ignoreCase: !(settings.caseSensitive ?? false),
|
|
63
61
|
};
|
|
64
62
|
return opt;
|
|
65
63
|
}
|
package/dist/trace.js
CHANGED
|
@@ -41,12 +41,11 @@ exports.traceWords = traceWords;
|
|
|
41
41
|
async function* traceWordsAsync(words, settings, options) {
|
|
42
42
|
const { languageId, locale: language, ignoreCase = true, allowCompoundWords } = options || {};
|
|
43
43
|
async function finalize(config) {
|
|
44
|
-
var _a;
|
|
45
44
|
const withLocale = (0, Settings_1.mergeSettings)(config, util.clean({
|
|
46
45
|
language: language || config.language,
|
|
47
|
-
allowCompoundWords: allowCompoundWords
|
|
46
|
+
allowCompoundWords: allowCompoundWords ?? config.allowCompoundWords,
|
|
48
47
|
}));
|
|
49
|
-
const withLanguageId = (0, LanguageSettings_1.calcSettingsForLanguageId)(withLocale,
|
|
48
|
+
const withLanguageId = (0, LanguageSettings_1.calcSettingsForLanguageId)(withLocale, languageId ?? withLocale.languageId ?? 'plaintext');
|
|
50
49
|
const settings = (0, Settings_1.finalizeSettings)(withLanguageId);
|
|
51
50
|
const dictionaries = (settings.dictionaries || [])
|
|
52
51
|
.concat((settings.dictionaryDefinitions || []).map((d) => d.name))
|
|
@@ -66,28 +65,25 @@ async function* traceWordsAsync(words, settings, options) {
|
|
|
66
65
|
const setOfActiveDicts = new Set(activeDictionaries);
|
|
67
66
|
const opts = util.clean({ ignoreCase, useCompounds: config.allowCompoundWords });
|
|
68
67
|
function normalizeErrors(errors) {
|
|
69
|
-
if (!
|
|
68
|
+
if (!errors?.length)
|
|
70
69
|
return undefined;
|
|
71
70
|
return errors;
|
|
72
71
|
}
|
|
73
72
|
function processWord(word) {
|
|
74
73
|
return dicts.dictionaries
|
|
75
74
|
.map((dict) => ({ dict, findResult: dict.find(word, opts) }))
|
|
76
|
-
.map(({ dict, findResult }) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
errors: normalizeErrors((_a = dict.getErrors) === null || _a === void 0 ? void 0 : _a.call(dict)),
|
|
89
|
-
});
|
|
90
|
-
});
|
|
75
|
+
.map(({ dict, findResult }) => ({
|
|
76
|
+
word,
|
|
77
|
+
found: !!findResult?.found,
|
|
78
|
+
foundWord: findResult?.found || undefined,
|
|
79
|
+
forbidden: findResult?.forbidden || false,
|
|
80
|
+
noSuggest: findResult?.noSuggest || false,
|
|
81
|
+
dictName: dict.name,
|
|
82
|
+
dictSource: dict.source,
|
|
83
|
+
dictActive: setOfActiveDicts.has(dict.name),
|
|
84
|
+
configSource: config.name || '',
|
|
85
|
+
errors: normalizeErrors(dict.getErrors?.()),
|
|
86
|
+
}));
|
|
91
87
|
}
|
|
92
88
|
for await (const word of words) {
|
|
93
89
|
yield processWord(word);
|
package/dist/util/Memorizer.js
CHANGED
|
@@ -95,20 +95,18 @@ exports.callOnce = callOnce;
|
|
|
95
95
|
function memorizerAll(fn) {
|
|
96
96
|
const r = {};
|
|
97
97
|
function find(p) {
|
|
98
|
-
var _a;
|
|
99
98
|
let n = r;
|
|
100
99
|
for (const k of p) {
|
|
101
100
|
if (!n)
|
|
102
101
|
break;
|
|
103
|
-
n =
|
|
102
|
+
n = n.c?.get(k);
|
|
104
103
|
}
|
|
105
104
|
return n;
|
|
106
105
|
}
|
|
107
106
|
function set(p, v) {
|
|
108
|
-
var _a;
|
|
109
107
|
let n = r;
|
|
110
108
|
for (const k of p) {
|
|
111
|
-
const c =
|
|
109
|
+
const c = n.c?.get(k);
|
|
112
110
|
if (c) {
|
|
113
111
|
n = c;
|
|
114
112
|
continue;
|
package/dist/util/PairingHeap.js
CHANGED
|
@@ -5,20 +5,18 @@ exports.memorizerWeak = void 0;
|
|
|
5
5
|
function memorizerWeak(fn) {
|
|
6
6
|
const r = {};
|
|
7
7
|
function find(p) {
|
|
8
|
-
var _a;
|
|
9
8
|
let n = r;
|
|
10
9
|
for (const k of p) {
|
|
11
10
|
if (!n)
|
|
12
11
|
break;
|
|
13
|
-
n =
|
|
12
|
+
n = n.c?.get(k);
|
|
14
13
|
}
|
|
15
14
|
return n;
|
|
16
15
|
}
|
|
17
16
|
function set(p, v) {
|
|
18
|
-
var _a;
|
|
19
17
|
let n = r;
|
|
20
18
|
for (const k of p) {
|
|
21
|
-
const c =
|
|
19
|
+
const c = n.c?.get(k);
|
|
22
20
|
if (c) {
|
|
23
21
|
n = c;
|
|
24
22
|
continue;
|
package/dist/util/search.js
CHANGED
|
@@ -6,8 +6,8 @@ exports.binarySearch = void 0;
|
|
|
6
6
|
* The value returned is either the position of the item or where it should be inserted.
|
|
7
7
|
*/
|
|
8
8
|
function binarySearch(arr, item, leftOffset, rightOffset) {
|
|
9
|
-
let left = Math.max(leftOffset
|
|
10
|
-
let right = Math.min(rightOffset
|
|
9
|
+
let left = Math.max(leftOffset ?? 0, 0);
|
|
10
|
+
let right = Math.min(rightOffset ?? arr.length, arr.length);
|
|
11
11
|
while (left < right) {
|
|
12
12
|
const pos = (left + right) >> 1;
|
|
13
13
|
if (arr[pos] < item) {
|
package/dist/util/text.js
CHANGED
|
@@ -199,7 +199,7 @@ function calculateTextDocumentOffsets(uri, doc, wordOffsets) {
|
|
|
199
199
|
function calcLine(row) {
|
|
200
200
|
const last = lastLineRow === row ? lastLine : undefined;
|
|
201
201
|
lastLineRow = row;
|
|
202
|
-
const r = last
|
|
202
|
+
const r = last ?? extractLine(row);
|
|
203
203
|
lastLine = r;
|
|
204
204
|
return r;
|
|
205
205
|
}
|
package/dist/util/timer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLapRecorder = exports.polyHrTime = exports.toMilliseconds = exports.createTimer = void 0;
|
|
4
|
-
const _hrTime =
|
|
4
|
+
const _hrTime = process?.hrtime || polyHrTime;
|
|
5
5
|
function createTimer(hrTimeFn = _hrTime) {
|
|
6
6
|
let start = hrTimeFn();
|
|
7
7
|
let lastLap = 0;
|
|
@@ -186,7 +186,6 @@ function genSymbolBreaks(line) {
|
|
|
186
186
|
];
|
|
187
187
|
}
|
|
188
188
|
function splitIntoWords(lineSeg, breaks, has) {
|
|
189
|
-
var _a;
|
|
190
189
|
const maxIndex = lineSeg.relEnd;
|
|
191
190
|
const maxAttempts = 1000;
|
|
192
191
|
const knownPathsByIndex = new Map();
|
|
@@ -242,11 +241,10 @@ function splitIntoWords(lineSeg, breaks, has) {
|
|
|
242
241
|
return results;
|
|
243
242
|
}
|
|
244
243
|
function addToKnownPaths(candidate, path) {
|
|
245
|
-
var _a;
|
|
246
244
|
for (let can = candidate; can !== undefined; can = can.p) {
|
|
247
245
|
const t = can.text;
|
|
248
246
|
const i = can.i;
|
|
249
|
-
const cost = (!t || t.isFound ? 0 : t.text.length) + (
|
|
247
|
+
const cost = (!t || t.isFound ? 0 : t.text.length) + (path?.c ?? 0);
|
|
250
248
|
const exitingPath = knownPathsByIndex.get(i);
|
|
251
249
|
// Keep going only if this is a better candidate than the existing path
|
|
252
250
|
if (exitingPath && exitingPath.c <= cost) {
|
|
@@ -307,7 +305,7 @@ function splitIntoWords(lineSeg, breaks, has) {
|
|
|
307
305
|
best.c += cost;
|
|
308
306
|
best.ec = best.c;
|
|
309
307
|
best.text = t;
|
|
310
|
-
const segText = t ||
|
|
308
|
+
const segText = t || best.p?.text || toTextOffset('', best.i);
|
|
311
309
|
const can = t ? { ...best, text: segText } : { ...best, ...best.p, text: segText };
|
|
312
310
|
const f = addToKnownPaths(can, undefined);
|
|
313
311
|
bestPath = !bestPath || (f && f.c < bestPath.c) ? f : bestPath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "6.1.0",
|
|
3
|
+
"version": "6.1.3-alpha.0",
|
|
4
4
|
"description": "A library of useful functions used across various cspell tools.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@cspell/cspell-bundled-dicts": "^6.1.0",
|
|
52
|
-
"@cspell/cspell-pipe": "^6.1.0",
|
|
53
|
-
"@cspell/cspell-types": "^6.1.0",
|
|
51
|
+
"@cspell/cspell-bundled-dicts": "^6.1.3-alpha.0",
|
|
52
|
+
"@cspell/cspell-pipe": "^6.1.3-alpha.0",
|
|
53
|
+
"@cspell/cspell-types": "^6.1.3-alpha.0",
|
|
54
54
|
"clear-module": "^4.1.2",
|
|
55
55
|
"comment-json": "^4.2.2",
|
|
56
56
|
"configstore": "^5.0.1",
|
|
57
57
|
"cosmiconfig": "^7.0.1",
|
|
58
|
-
"cspell-glob": "^6.1.0",
|
|
59
|
-
"cspell-io": "^6.1.0",
|
|
60
|
-
"cspell-trie-lib": "^6.1.0",
|
|
61
|
-
"fast-equals": "^
|
|
58
|
+
"cspell-glob": "^6.1.3-alpha.0",
|
|
59
|
+
"cspell-io": "^6.1.3-alpha.0",
|
|
60
|
+
"cspell-trie-lib": "^6.1.3-alpha.0",
|
|
61
|
+
"fast-equals": "^4.0.1",
|
|
62
62
|
"find-up": "^5.0.0",
|
|
63
63
|
"fs-extra": "^10.1.0",
|
|
64
64
|
"gensequence": "^3.1.1",
|
|
@@ -82,15 +82,15 @@
|
|
|
82
82
|
"@cspell/dict-python": "^2.0.6",
|
|
83
83
|
"@types/configstore": "^5.0.1",
|
|
84
84
|
"@types/fs-extra": "^9.0.13",
|
|
85
|
-
"@types/jest": "^
|
|
86
|
-
"@types/node": "^17.0.
|
|
85
|
+
"@types/jest": "^28.1.1",
|
|
86
|
+
"@types/node": "^17.0.43",
|
|
87
87
|
"cspell-dict-nl-nl": "^1.1.2",
|
|
88
|
-
"jest": "^28.1.
|
|
89
|
-
"lorem-ipsum": "^2.0.
|
|
88
|
+
"jest": "^28.1.1",
|
|
89
|
+
"lorem-ipsum": "^2.0.8",
|
|
90
90
|
"rimraf": "^3.0.2",
|
|
91
|
-
"rollup": "^2.75.
|
|
91
|
+
"rollup": "^2.75.6",
|
|
92
92
|
"rollup-plugin-dts": "^4.2.2",
|
|
93
|
-
"ts-jest": "^28.0.
|
|
93
|
+
"ts-jest": "^28.0.5"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "b3cde7e463fd8a6f2c03f990adc70b913239baeb"
|
|
96
96
|
}
|