cspell-lib 6.30.2 → 6.31.1
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/cjs/Settings/CSpellSettingsServer.js +15 -21
- package/dist/cjs/Settings/Controller/configLoader/normalizeRawSettings.d.ts +1 -1
- package/dist/cjs/Settings/LanguageSettings.js +1 -1
- package/dist/cjs/textValidation/checkText.js +2 -1
- package/dist/cjs/util/textRegex.d.ts +1 -0
- package/dist/cjs/util/textRegex.js +5 -3
- package/dist/cjs/util/util.d.ts +1 -1
- package/dist/cjs/util/util.js +2 -2
- package/dist/cjs/util/wordSplitter.d.ts +2 -0
- package/dist/cjs/util/wordSplitter.js +9 -0
- package/dist/esm/Settings/CSpellSettingsServer.mjs +15 -21
- package/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.d.mts +1 -1
- package/dist/esm/Settings/LanguageSettings.mjs +1 -1
- package/dist/esm/textValidation/checkText.mjs +2 -1
- package/dist/esm/util/textRegex.d.mts +1 -0
- package/dist/esm/util/textRegex.mjs +4 -2
- package/dist/esm/util/util.d.mts +1 -1
- package/dist/esm/util/util.mjs +2 -2
- package/dist/esm/util/wordSplitter.d.mts +2 -0
- package/dist/esm/util/wordSplitter.mjs +10 -1
- package/package.json +11 -11
|
@@ -36,24 +36,21 @@ const util = __importStar(require("../util/util.js"));
|
|
|
36
36
|
const constants_js_1 = require("./constants.js");
|
|
37
37
|
const DictionarySettings_js_1 = require("./DictionarySettings.js");
|
|
38
38
|
const patterns_js_1 = require("./patterns.js");
|
|
39
|
-
function _unique(a) {
|
|
40
|
-
return [...new Set(a)];
|
|
41
|
-
}
|
|
42
39
|
function mergeListUnique(left, right) {
|
|
43
|
-
if (left
|
|
44
|
-
return right;
|
|
45
|
-
if (right
|
|
40
|
+
if (!Array.isArray(left))
|
|
41
|
+
return Array.isArray(right) ? right : undefined;
|
|
42
|
+
if (!Array.isArray(right))
|
|
46
43
|
return left;
|
|
47
44
|
if (!right.length)
|
|
48
45
|
return left;
|
|
49
46
|
if (!left.length)
|
|
50
47
|
return right;
|
|
51
|
-
return
|
|
48
|
+
return [...new Set([...left, ...right])];
|
|
52
49
|
}
|
|
53
50
|
function mergeList(left, right) {
|
|
54
|
-
if (left
|
|
55
|
-
return right;
|
|
56
|
-
if (right
|
|
51
|
+
if (!Array.isArray(left))
|
|
52
|
+
return Array.isArray(right) ? right : undefined;
|
|
53
|
+
if (!Array.isArray(right))
|
|
57
54
|
return left;
|
|
58
55
|
if (!left.length)
|
|
59
56
|
return right;
|
|
@@ -69,20 +66,17 @@ function _mergeWordsCached(left, right) {
|
|
|
69
66
|
return (0, AutoResolve_js_1.autoResolveWeak)(map, right, () => left.concat(right));
|
|
70
67
|
}
|
|
71
68
|
function mergeWordsCached(left, right) {
|
|
72
|
-
if (left
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return !right || right.length ? right : emptyWords;
|
|
78
|
-
if (!right.length)
|
|
79
|
-
return !left || left.length ? left : emptyWords;
|
|
69
|
+
if (!Array.isArray(left) || !left.length) {
|
|
70
|
+
return Array.isArray(right) ? (right.length ? right : emptyWords) : undefined;
|
|
71
|
+
}
|
|
72
|
+
if (!Array.isArray(right) || !right.length)
|
|
73
|
+
return left;
|
|
80
74
|
return _mergeWordsCached(left, right);
|
|
81
75
|
}
|
|
82
76
|
function mergeObjects(left, right) {
|
|
83
|
-
if (left
|
|
84
|
-
return right;
|
|
85
|
-
if (right
|
|
77
|
+
if (!left || typeof left !== 'object')
|
|
78
|
+
return !right || typeof right !== 'object' ? undefined : right;
|
|
79
|
+
if (!right || typeof right !== 'object')
|
|
86
80
|
return left;
|
|
87
81
|
return { ...left, ...right };
|
|
88
82
|
}
|
|
@@ -9,7 +9,7 @@ export declare function normalizeDictionaryDefs(settings: NormalizeDictionaryDef
|
|
|
9
9
|
dictionaryDefinitions: import("../../../Models/CSpellSettingsInternalDef.js").DictionaryDefinitionInternalWithSource[] | undefined;
|
|
10
10
|
languageSettings: import("../../../util/types.js").RemoveUndefined<{
|
|
11
11
|
dictionaryDefinitions: import("../../../Models/CSpellSettingsInternalDef.js").DictionaryDefinitionInternalWithSource[] | undefined;
|
|
12
|
-
languageId:
|
|
12
|
+
languageId: import("@cspell/cspell-types").MatchingFileType;
|
|
13
13
|
locale?: string | string[];
|
|
14
14
|
local?: string | string[];
|
|
15
15
|
id?: string;
|
|
@@ -151,7 +151,7 @@ function calcUserSettingsForLanguage(settings, languageId) {
|
|
|
151
151
|
}
|
|
152
152
|
exports.calcUserSettingsForLanguage = calcUserSettingsForLanguage;
|
|
153
153
|
function calcSettingsForLanguageId(baseSettings, languageId) {
|
|
154
|
-
const langIds = ['*'
|
|
154
|
+
const langIds = ['*', ...normalizeLanguageId(languageId)];
|
|
155
155
|
const langSettings = langIds.reduce((settings, languageId) => {
|
|
156
156
|
return calcUserSettingsForLanguage(settings, languageId);
|
|
157
157
|
}, baseSettings);
|
|
@@ -43,10 +43,11 @@ const validator_js_1 = require("./validator.js");
|
|
|
43
43
|
* @deprecated
|
|
44
44
|
*/
|
|
45
45
|
async function checkText(text, settings) {
|
|
46
|
+
const languageId = settings.languageId || 'plaintext';
|
|
46
47
|
const doc = (0, util_js_1.clean)({
|
|
47
48
|
uri: '',
|
|
48
49
|
text,
|
|
49
|
-
languageId:
|
|
50
|
+
languageId: Array.isArray(languageId) ? languageId.join(',') : languageId,
|
|
50
51
|
locale: settings.language,
|
|
51
52
|
});
|
|
52
53
|
return checkTextDocument(doc, { noConfigSearch: true }, { loadDefaultConfiguration: false, ...settings });
|
|
@@ -15,5 +15,6 @@ export declare const regExEscapeCharacters: RegExp;
|
|
|
15
15
|
export declare const regExDanglingQuote: RegExp;
|
|
16
16
|
/** Match tailing endings after CAPS words */
|
|
17
17
|
export declare const regExTrailingEndings: RegExp;
|
|
18
|
+
export declare const regExNumericLiteral: RegExp;
|
|
18
19
|
export declare function stringToRegExp(pattern: string | RegExp, defaultFlags?: string, forceFlags?: string): RegExp | undefined;
|
|
19
20
|
//# sourceMappingURL=textRegex.d.ts.map
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// cspell:ignore ings ning gimuy anrvtbf gimuxy
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.stringToRegExp = exports.regExTrailingEndings = exports.regExDanglingQuote = exports.regExEscapeCharacters = exports.regExAccents = exports.regExMatchRegExParts = exports.regExPossibleWordBreaks = exports.regExAllLower = exports.regExAllUpper = exports.regExFirstUpper = exports.regExIgnoreCharacters = exports.regExWordsAndDigits = exports.regExWords = exports.regExSplitWords2 = exports.regExSplitWords = exports.regExUpperSOrIng = void 0;
|
|
4
|
+
exports.stringToRegExp = exports.regExNumericLiteral = exports.regExTrailingEndings = exports.regExDanglingQuote = exports.regExEscapeCharacters = exports.regExAccents = exports.regExMatchRegExParts = exports.regExPossibleWordBreaks = exports.regExAllLower = exports.regExAllUpper = exports.regExFirstUpper = exports.regExIgnoreCharacters = exports.regExWordsAndDigits = exports.regExWords = exports.regExSplitWords2 = exports.regExSplitWords = exports.regExUpperSOrIng = void 0;
|
|
5
5
|
exports.regExUpperSOrIng = /([\p{Lu}\p{M}]+\\?['’]?(?:s|ing|ies|es|ings|ed|ning))(?!\p{Ll})/gu;
|
|
6
6
|
exports.regExSplitWords = /(\p{Ll}\p{M}?)(\p{Lu})/gu;
|
|
7
7
|
exports.regExSplitWords2 = /(\p{Lu}\p{M}?)(\p{Lu}\p{M}?\p{Ll})/gu;
|
|
8
8
|
exports.regExWords = /\p{L}\p{M}?(?:(?:\\?['’])?\p{L}\p{M}?)*/gu;
|
|
9
|
-
|
|
9
|
+
// Words can be made of letters, numbers, period, underscore, dash, plus, and single quote
|
|
10
|
+
exports.regExWordsAndDigits = /[\p{L}\w'’`.+-](?:(?:\\(?=[']))?[\p{L}\p{M}\w'’`.+-])*/gu;
|
|
10
11
|
exports.regExIgnoreCharacters = /[\p{sc=Hiragana}\p{sc=Han}\p{sc=Katakana}\u30A0-\u30FF\p{sc=Hangul}]/gu;
|
|
11
12
|
exports.regExFirstUpper = /^\p{Lu}\p{M}?\p{Ll}+$/u;
|
|
12
13
|
exports.regExAllUpper = /^(?:\p{Lu}\p{M}?)+$/u;
|
|
13
14
|
exports.regExAllLower = /^(?:\p{Ll}\p{M}?)+$/u;
|
|
14
|
-
exports.regExPossibleWordBreaks = /[
|
|
15
|
+
exports.regExPossibleWordBreaks = /[-+_’'`.\s]/g;
|
|
15
16
|
exports.regExMatchRegExParts = /^\s*\/([\s\S]*?)\/([gimuxy]*)\s*$/;
|
|
16
17
|
exports.regExAccents = /\p{M}/gu;
|
|
17
18
|
exports.regExEscapeCharacters = /(?<=\\)[anrvtbf]/gi;
|
|
@@ -19,6 +20,7 @@ exports.regExEscapeCharacters = /(?<=\\)[anrvtbf]/gi;
|
|
|
19
20
|
exports.regExDanglingQuote = /(?<=(?:^|(?!\p{M})\P{L})(?:\p{L}\p{M}?)?)[']/gu;
|
|
20
21
|
/** Match tailing endings after CAPS words */
|
|
21
22
|
exports.regExTrailingEndings = /(?<=(?:\p{Lu}\p{M}?){2})['’]?(?:s|d|ings?|ies|e[ds]?|ning|th|nth)(?!\p{Ll})/gu;
|
|
23
|
+
exports.regExNumericLiteral = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;
|
|
22
24
|
function stringToRegExp(pattern, defaultFlags = 'gimu', forceFlags = 'g') {
|
|
23
25
|
if (pattern instanceof RegExp) {
|
|
24
26
|
return pattern;
|
package/dist/cjs/util/util.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare function uniqueFilterFnGenerator<T>(): (v: T) => boolean;
|
|
|
4
4
|
export declare function uniqueFilterFnGenerator<T, U>(extractFn: (v: T) => U): (v: T) => boolean;
|
|
5
5
|
export declare function unique<T>(src: T[]): T[];
|
|
6
6
|
/**
|
|
7
|
-
* Delete all `undefined` fields from an object.
|
|
7
|
+
* Delete all `undefined` and `null` fields from an object.
|
|
8
8
|
* @param src - object to be cleaned
|
|
9
9
|
*/
|
|
10
10
|
export declare function clean<T extends object>(src: T): RemoveUndefined<T>;
|
package/dist/cjs/util/util.js
CHANGED
|
@@ -19,13 +19,13 @@ function unique(src) {
|
|
|
19
19
|
}
|
|
20
20
|
exports.unique = unique;
|
|
21
21
|
/**
|
|
22
|
-
* Delete all `undefined` fields from an object.
|
|
22
|
+
* Delete all `undefined` and `null` fields from an object.
|
|
23
23
|
* @param src - object to be cleaned
|
|
24
24
|
*/
|
|
25
25
|
function clean(src) {
|
|
26
26
|
const r = src;
|
|
27
27
|
for (const key of Object.keys(r)) {
|
|
28
|
-
if (r[key] === undefined) {
|
|
28
|
+
if (r[key] === undefined || r[key] === null) {
|
|
29
29
|
delete r[key];
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -23,6 +23,7 @@ export interface TextOffsetWithValid extends TextOffset {
|
|
|
23
23
|
export interface SplitOptions extends WordBreakOptions {
|
|
24
24
|
}
|
|
25
25
|
export declare function split(line: TextOffset, offset: number, isValidWord: IsValidWordFn, options?: SplitOptions): SplitResult;
|
|
26
|
+
declare function findNextWordText({ text, offset }: TextOffset): TextOffset;
|
|
26
27
|
type BreakPairs = readonly number[];
|
|
27
28
|
interface PossibleWordBreak {
|
|
28
29
|
/** offset from the start of the string */
|
|
@@ -41,6 +42,7 @@ interface WordBreakOptions {
|
|
|
41
42
|
declare function generateWordBreaks(line: LineSegment, options: WordBreakOptions): SortedBreaks;
|
|
42
43
|
export declare const __testing__: {
|
|
43
44
|
generateWordBreaks: typeof generateWordBreaks;
|
|
45
|
+
findNextWordText: typeof findNextWordText;
|
|
44
46
|
};
|
|
45
47
|
export {};
|
|
46
48
|
//# sourceMappingURL=wordSplitter.d.ts.map
|
|
@@ -9,6 +9,7 @@ function split(line, offset, isValidWord, options = {}) {
|
|
|
9
9
|
const relWordToSplit = findNextWordText({ text: line.text, offset: offset - line.offset });
|
|
10
10
|
const lineOffset = line.offset;
|
|
11
11
|
const requested = new Map();
|
|
12
|
+
const regExpIgnoreSegment = /^[-.+\d_eE'`\\\s]+$/;
|
|
12
13
|
if (!relWordToSplit.text) {
|
|
13
14
|
const text = rebaseTextOffset(relWordToSplit);
|
|
14
15
|
return {
|
|
@@ -42,6 +43,9 @@ function split(line, offset, isValidWord, options = {}) {
|
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
function has(word) {
|
|
46
|
+
if (regExpIgnoreSegment.test(word.text)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
45
49
|
const i = word.offset;
|
|
46
50
|
const j = word.text.length;
|
|
47
51
|
let v = i + (j << 20);
|
|
@@ -84,6 +88,10 @@ function findNextWordText({ text, offset }) {
|
|
|
84
88
|
offset: offset + text.length,
|
|
85
89
|
};
|
|
86
90
|
}
|
|
91
|
+
// Skip numeric literals.
|
|
92
|
+
if (textRegex_js_1.regExNumericLiteral.test(m[0])) {
|
|
93
|
+
return findNextWordText({ text, offset: offset + m[0].length });
|
|
94
|
+
}
|
|
87
95
|
return {
|
|
88
96
|
text: m[0],
|
|
89
97
|
offset: m.index,
|
|
@@ -322,5 +330,6 @@ function mergeSortedBreaks(...maps) {
|
|
|
322
330
|
}
|
|
323
331
|
exports.__testing__ = {
|
|
324
332
|
generateWordBreaks,
|
|
333
|
+
findNextWordText,
|
|
325
334
|
};
|
|
326
335
|
//# sourceMappingURL=wordSplitter.js.map
|
|
@@ -7,24 +7,21 @@ import * as util from '../util/util.mjs';
|
|
|
7
7
|
import { configSettingsFileVersion0_1, ENV_CSPELL_GLOB_ROOT } from './constants.mjs';
|
|
8
8
|
import { calcDictionaryDefsToLoad, mapDictDefsToInternal } from './DictionarySettings.mjs';
|
|
9
9
|
import { resolvePatterns } from './patterns.mjs';
|
|
10
|
-
function _unique(a) {
|
|
11
|
-
return [...new Set(a)];
|
|
12
|
-
}
|
|
13
10
|
function mergeListUnique(left, right) {
|
|
14
|
-
if (left
|
|
15
|
-
return right;
|
|
16
|
-
if (right
|
|
11
|
+
if (!Array.isArray(left))
|
|
12
|
+
return Array.isArray(right) ? right : undefined;
|
|
13
|
+
if (!Array.isArray(right))
|
|
17
14
|
return left;
|
|
18
15
|
if (!right.length)
|
|
19
16
|
return left;
|
|
20
17
|
if (!left.length)
|
|
21
18
|
return right;
|
|
22
|
-
return
|
|
19
|
+
return [...new Set([...left, ...right])];
|
|
23
20
|
}
|
|
24
21
|
function mergeList(left, right) {
|
|
25
|
-
if (left
|
|
26
|
-
return right;
|
|
27
|
-
if (right
|
|
22
|
+
if (!Array.isArray(left))
|
|
23
|
+
return Array.isArray(right) ? right : undefined;
|
|
24
|
+
if (!Array.isArray(right))
|
|
28
25
|
return left;
|
|
29
26
|
if (!left.length)
|
|
30
27
|
return right;
|
|
@@ -40,20 +37,17 @@ function _mergeWordsCached(left, right) {
|
|
|
40
37
|
return autoResolveWeak(map, right, () => left.concat(right));
|
|
41
38
|
}
|
|
42
39
|
function mergeWordsCached(left, right) {
|
|
43
|
-
if (left
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return !right || right.length ? right : emptyWords;
|
|
49
|
-
if (!right.length)
|
|
50
|
-
return !left || left.length ? left : emptyWords;
|
|
40
|
+
if (!Array.isArray(left) || !left.length) {
|
|
41
|
+
return Array.isArray(right) ? (right.length ? right : emptyWords) : undefined;
|
|
42
|
+
}
|
|
43
|
+
if (!Array.isArray(right) || !right.length)
|
|
44
|
+
return left;
|
|
51
45
|
return _mergeWordsCached(left, right);
|
|
52
46
|
}
|
|
53
47
|
function mergeObjects(left, right) {
|
|
54
|
-
if (left
|
|
55
|
-
return right;
|
|
56
|
-
if (right
|
|
48
|
+
if (!left || typeof left !== 'object')
|
|
49
|
+
return !right || typeof right !== 'object' ? undefined : right;
|
|
50
|
+
if (!right || typeof right !== 'object')
|
|
57
51
|
return left;
|
|
58
52
|
return { ...left, ...right };
|
|
59
53
|
}
|
|
@@ -9,7 +9,7 @@ export declare function normalizeDictionaryDefs(settings: NormalizeDictionaryDef
|
|
|
9
9
|
dictionaryDefinitions: import("../../../Models/CSpellSettingsInternalDef.js").DictionaryDefinitionInternalWithSource[] | undefined;
|
|
10
10
|
languageSettings: import("../../../util/types.js").RemoveUndefined<{
|
|
11
11
|
dictionaryDefinitions: import("../../../Models/CSpellSettingsInternalDef.js").DictionaryDefinitionInternalWithSource[] | undefined;
|
|
12
|
-
languageId:
|
|
12
|
+
languageId: import("@cspell/cspell-types").MatchingFileType;
|
|
13
13
|
locale?: string | string[];
|
|
14
14
|
local?: string | string[];
|
|
15
15
|
id?: string;
|
|
@@ -117,7 +117,7 @@ export function calcUserSettingsForLanguage(settings, languageId) {
|
|
|
117
117
|
return SpellSettings.mergeSettings(settings, langSettings);
|
|
118
118
|
}
|
|
119
119
|
export function calcSettingsForLanguageId(baseSettings, languageId) {
|
|
120
|
-
const langIds = ['*'
|
|
120
|
+
const langIds = ['*', ...normalizeLanguageId(languageId)];
|
|
121
121
|
const langSettings = langIds.reduce((settings, languageId) => {
|
|
122
122
|
return calcUserSettingsForLanguage(settings, languageId);
|
|
123
123
|
}, baseSettings);
|
|
@@ -14,10 +14,11 @@ import { validateText } from './validator.mjs';
|
|
|
14
14
|
* @deprecated
|
|
15
15
|
*/
|
|
16
16
|
export async function checkText(text, settings) {
|
|
17
|
+
const languageId = settings.languageId || 'plaintext';
|
|
17
18
|
const doc = clean({
|
|
18
19
|
uri: '',
|
|
19
20
|
text,
|
|
20
|
-
languageId:
|
|
21
|
+
languageId: Array.isArray(languageId) ? languageId.join(',') : languageId,
|
|
21
22
|
locale: settings.language,
|
|
22
23
|
});
|
|
23
24
|
return checkTextDocument(doc, { noConfigSearch: true }, { loadDefaultConfiguration: false, ...settings });
|
|
@@ -15,5 +15,6 @@ export declare const regExEscapeCharacters: RegExp;
|
|
|
15
15
|
export declare const regExDanglingQuote: RegExp;
|
|
16
16
|
/** Match tailing endings after CAPS words */
|
|
17
17
|
export declare const regExTrailingEndings: RegExp;
|
|
18
|
+
export declare const regExNumericLiteral: RegExp;
|
|
18
19
|
export declare function stringToRegExp(pattern: string | RegExp, defaultFlags?: string, forceFlags?: string): RegExp | undefined;
|
|
19
20
|
//# sourceMappingURL=textRegex.d.mts.map
|
|
@@ -3,12 +3,13 @@ export const regExUpperSOrIng = /([\p{Lu}\p{M}]+\\?['’]?(?:s|ing|ies|es|ings|e
|
|
|
3
3
|
export const regExSplitWords = /(\p{Ll}\p{M}?)(\p{Lu})/gu;
|
|
4
4
|
export const regExSplitWords2 = /(\p{Lu}\p{M}?)(\p{Lu}\p{M}?\p{Ll})/gu;
|
|
5
5
|
export const regExWords = /\p{L}\p{M}?(?:(?:\\?['’])?\p{L}\p{M}?)*/gu;
|
|
6
|
-
|
|
6
|
+
// Words can be made of letters, numbers, period, underscore, dash, plus, and single quote
|
|
7
|
+
export const regExWordsAndDigits = /[\p{L}\w'’`.+-](?:(?:\\(?=[']))?[\p{L}\p{M}\w'’`.+-])*/gu;
|
|
7
8
|
export const regExIgnoreCharacters = /[\p{sc=Hiragana}\p{sc=Han}\p{sc=Katakana}\u30A0-\u30FF\p{sc=Hangul}]/gu;
|
|
8
9
|
export const regExFirstUpper = /^\p{Lu}\p{M}?\p{Ll}+$/u;
|
|
9
10
|
export const regExAllUpper = /^(?:\p{Lu}\p{M}?)+$/u;
|
|
10
11
|
export const regExAllLower = /^(?:\p{Ll}\p{M}?)+$/u;
|
|
11
|
-
export const regExPossibleWordBreaks = /[
|
|
12
|
+
export const regExPossibleWordBreaks = /[-+_’'`.\s]/g;
|
|
12
13
|
export const regExMatchRegExParts = /^\s*\/([\s\S]*?)\/([gimuxy]*)\s*$/;
|
|
13
14
|
export const regExAccents = /\p{M}/gu;
|
|
14
15
|
export const regExEscapeCharacters = /(?<=\\)[anrvtbf]/gi;
|
|
@@ -16,6 +17,7 @@ export const regExEscapeCharacters = /(?<=\\)[anrvtbf]/gi;
|
|
|
16
17
|
export const regExDanglingQuote = /(?<=(?:^|(?!\p{M})\P{L})(?:\p{L}\p{M}?)?)[']/gu;
|
|
17
18
|
/** Match tailing endings after CAPS words */
|
|
18
19
|
export const regExTrailingEndings = /(?<=(?:\p{Lu}\p{M}?){2})['’]?(?:s|d|ings?|ies|e[ds]?|ning|th|nth)(?!\p{Ll})/gu;
|
|
20
|
+
export const regExNumericLiteral = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;
|
|
19
21
|
export function stringToRegExp(pattern, defaultFlags = 'gimu', forceFlags = 'g') {
|
|
20
22
|
if (pattern instanceof RegExp) {
|
|
21
23
|
return pattern;
|
package/dist/esm/util/util.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ export declare function uniqueFilterFnGenerator<T>(): (v: T) => boolean;
|
|
|
4
4
|
export declare function uniqueFilterFnGenerator<T, U>(extractFn: (v: T) => U): (v: T) => boolean;
|
|
5
5
|
export declare function unique<T>(src: T[]): T[];
|
|
6
6
|
/**
|
|
7
|
-
* Delete all `undefined` fields from an object.
|
|
7
|
+
* Delete all `undefined` and `null` fields from an object.
|
|
8
8
|
* @param src - object to be cleaned
|
|
9
9
|
*/
|
|
10
10
|
export declare function clean<T extends object>(src: T): RemoveUndefined<T>;
|
package/dist/esm/util/util.mjs
CHANGED
|
@@ -14,13 +14,13 @@ export function unique(src) {
|
|
|
14
14
|
return [...new Set(src)];
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Delete all `undefined` fields from an object.
|
|
17
|
+
* Delete all `undefined` and `null` fields from an object.
|
|
18
18
|
* @param src - object to be cleaned
|
|
19
19
|
*/
|
|
20
20
|
export function clean(src) {
|
|
21
21
|
const r = src;
|
|
22
22
|
for (const key of Object.keys(r)) {
|
|
23
|
-
if (r[key] === undefined) {
|
|
23
|
+
if (r[key] === undefined || r[key] === null) {
|
|
24
24
|
delete r[key];
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -23,6 +23,7 @@ export interface TextOffsetWithValid extends TextOffset {
|
|
|
23
23
|
export interface SplitOptions extends WordBreakOptions {
|
|
24
24
|
}
|
|
25
25
|
export declare function split(line: TextOffset, offset: number, isValidWord: IsValidWordFn, options?: SplitOptions): SplitResult;
|
|
26
|
+
declare function findNextWordText({ text, offset }: TextOffset): TextOffset;
|
|
26
27
|
type BreakPairs = readonly number[];
|
|
27
28
|
interface PossibleWordBreak {
|
|
28
29
|
/** offset from the start of the string */
|
|
@@ -41,6 +42,7 @@ interface WordBreakOptions {
|
|
|
41
42
|
declare function generateWordBreaks(line: LineSegment, options: WordBreakOptions): SortedBreaks;
|
|
42
43
|
export declare const __testing__: {
|
|
43
44
|
generateWordBreaks: typeof generateWordBreaks;
|
|
45
|
+
findNextWordText: typeof findNextWordText;
|
|
44
46
|
};
|
|
45
47
|
export {};
|
|
46
48
|
//# sourceMappingURL=wordSplitter.d.mts.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { PairingHeap } from './PairingHeap.mjs';
|
|
2
2
|
import { escapeRegEx } from './regexHelper.mjs';
|
|
3
|
-
import { regExDanglingQuote, regExEscapeCharacters, regExPossibleWordBreaks, regExSplitWords, regExSplitWords2, regExTrailingEndings, regExWordsAndDigits, } from './textRegex.mjs';
|
|
3
|
+
import { regExDanglingQuote, regExEscapeCharacters, regExNumericLiteral, regExPossibleWordBreaks, regExSplitWords, regExSplitWords2, regExTrailingEndings, regExWordsAndDigits, } from './textRegex.mjs';
|
|
4
4
|
const ignoreBreak = Object.freeze([]);
|
|
5
5
|
export function split(line, offset, isValidWord, options = {}) {
|
|
6
6
|
const relWordToSplit = findNextWordText({ text: line.text, offset: offset - line.offset });
|
|
7
7
|
const lineOffset = line.offset;
|
|
8
8
|
const requested = new Map();
|
|
9
|
+
const regExpIgnoreSegment = /^[-.+\d_eE'`\\\s]+$/;
|
|
9
10
|
if (!relWordToSplit.text) {
|
|
10
11
|
const text = rebaseTextOffset(relWordToSplit);
|
|
11
12
|
return {
|
|
@@ -39,6 +40,9 @@ export function split(line, offset, isValidWord, options = {}) {
|
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
function has(word) {
|
|
43
|
+
if (regExpIgnoreSegment.test(word.text)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
42
46
|
const i = word.offset;
|
|
43
47
|
const j = word.text.length;
|
|
44
48
|
let v = i + (j << 20);
|
|
@@ -80,6 +84,10 @@ function findNextWordText({ text, offset }) {
|
|
|
80
84
|
offset: offset + text.length,
|
|
81
85
|
};
|
|
82
86
|
}
|
|
87
|
+
// Skip numeric literals.
|
|
88
|
+
if (regExNumericLiteral.test(m[0])) {
|
|
89
|
+
return findNextWordText({ text, offset: offset + m[0].length });
|
|
90
|
+
}
|
|
83
91
|
return {
|
|
84
92
|
text: m[0],
|
|
85
93
|
offset: m.index,
|
|
@@ -318,4 +326,5 @@ function mergeSortedBreaks(...maps) {
|
|
|
318
326
|
}
|
|
319
327
|
export const __testing__ = {
|
|
320
328
|
generateWordBreaks,
|
|
329
|
+
findNextWordText,
|
|
321
330
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.31.1",
|
|
4
4
|
"description": "A library of useful functions used across various cspell tools.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -57,19 +57,19 @@
|
|
|
57
57
|
},
|
|
58
58
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@cspell/cspell-bundled-dicts": "6.
|
|
61
|
-
"@cspell/cspell-pipe": "6.
|
|
62
|
-
"@cspell/cspell-types": "6.
|
|
63
|
-
"@cspell/strong-weak-map": "6.
|
|
60
|
+
"@cspell/cspell-bundled-dicts": "6.31.1",
|
|
61
|
+
"@cspell/cspell-pipe": "6.31.1",
|
|
62
|
+
"@cspell/cspell-types": "6.31.1",
|
|
63
|
+
"@cspell/strong-weak-map": "6.31.1",
|
|
64
64
|
"clear-module": "^4.1.2",
|
|
65
65
|
"comment-json": "^4.2.3",
|
|
66
66
|
"configstore": "^5.0.1",
|
|
67
67
|
"cosmiconfig": "8.0.0",
|
|
68
|
-
"cspell-dictionary": "6.
|
|
69
|
-
"cspell-glob": "6.
|
|
70
|
-
"cspell-grammar": "6.
|
|
71
|
-
"cspell-io": "6.
|
|
72
|
-
"cspell-trie-lib": "6.
|
|
68
|
+
"cspell-dictionary": "6.31.1",
|
|
69
|
+
"cspell-glob": "6.31.1",
|
|
70
|
+
"cspell-grammar": "6.31.1",
|
|
71
|
+
"cspell-io": "6.31.1",
|
|
72
|
+
"cspell-trie-lib": "6.31.1",
|
|
73
73
|
"fast-equals": "^4.0.3",
|
|
74
74
|
"find-up": "^5.0.0",
|
|
75
75
|
"gensequence": "^5.0.2",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"lorem-ipsum": "^2.0.8",
|
|
100
100
|
"ts-jest": "^29.0.5"
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "43c3652e27588f6643cf78fd764f12f497f89fbf"
|
|
103
103
|
}
|