cspell-lib 6.30.2 → 6.31.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.
@@ -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: string | string[];
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 = ['*'].concat(languageId instanceof Array ? languageId : [languageId]);
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: settings.languageId || 'plaintext',
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
- exports.regExWordsAndDigits = /(?:\d+)?[\p{L}\p{M}_'’-](?:(?:\\?['’])?[\p{L}\p{M}\w'’.-])*/gu;
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 = /[-_’'.]/g;
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;
@@ -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
@@ -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: string | string[];
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 = ['*'].concat(languageId instanceof Array ? languageId : [languageId]);
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: settings.languageId || 'plaintext',
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
- export const regExWordsAndDigits = /(?:\d+)?[\p{L}\p{M}_'’-](?:(?:\\?['’])?[\p{L}\p{M}\w'’.-])*/gu;
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 = /[-_’'.]/g;
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;
@@ -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.30.2",
3
+ "version": "6.31.0",
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.30.2",
61
- "@cspell/cspell-pipe": "6.30.2",
62
- "@cspell/cspell-types": "6.30.2",
63
- "@cspell/strong-weak-map": "6.30.2",
60
+ "@cspell/cspell-bundled-dicts": "6.31.0",
61
+ "@cspell/cspell-pipe": "6.31.0",
62
+ "@cspell/cspell-types": "6.31.0",
63
+ "@cspell/strong-weak-map": "6.31.0",
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.30.2",
69
- "cspell-glob": "6.30.2",
70
- "cspell-grammar": "6.30.2",
71
- "cspell-io": "6.30.2",
72
- "cspell-trie-lib": "6.30.2",
68
+ "cspell-dictionary": "6.31.0",
69
+ "cspell-glob": "6.31.0",
70
+ "cspell-grammar": "6.31.0",
71
+ "cspell-io": "6.31.0",
72
+ "cspell-trie-lib": "6.31.0",
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": "4da6895c680084f3b741ad24a73c5bb011a57b35"
102
+ "gitHead": "1c0c3eb875bc1aab334bd56d952c0d0964468b7a"
103
103
  }