cspell-lib 10.3.0-alpha.0 → 10.3.1-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.
@@ -60,6 +60,8 @@ const handlers = {
60
60
  readonly: skip,
61
61
  reporters: skip,
62
62
  showStatus: copy1,
63
+ softWordBreakDefinitions: copy1,
64
+ softWordBreaks: copy1,
63
65
  spellCheckDelayMs: copy1,
64
66
  substitutionDefinitions: copy1,
65
67
  substitutions: copy1,
@@ -180,6 +182,8 @@ const LanguageSettingsHandlers = {
180
182
  name: skip,
181
183
  noSuggestDictionaries: copy1,
182
184
  patterns: copyPatternsField,
185
+ softWordBreaks: copy1,
186
+ softWordBreakDefinitions: copy1,
183
187
  substitutionDefinitions: copy1,
184
188
  substitutions: copy1,
185
189
  suggestWords: copy1,
@@ -241,6 +245,8 @@ const OverridesHandlers = {
241
245
  numSuggestions: copy1,
242
246
  patterns: copyPatternsField,
243
247
  pnpFiles: skip,
248
+ softWordBreaks: copy1,
249
+ softWordBreakDefinitions: copy1,
244
250
  substitutionDefinitions: copy1,
245
251
  substitutions: copy1,
246
252
  suggestionNumChanges: copy1,
@@ -52,7 +52,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
52
52
  });
53
53
  import { opConcatMap, opFilter, opMap, pipe } from '@cspell/cspell-pipe/sync';
54
54
  import { StrongWeakMap } from '@cspell/strong-weak-map';
55
- import { createFailedToLoadDictionary, createFlagWordsDictionary, createFlagWordsDictionaryFromTrieFile, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, } from 'cspell-dictionary';
55
+ import { createFailedToLoadDictionary, createFlagWordsDictionary, createFlagWordsDictionaryFromTrieFile, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, createSuggestDictionaryFromTrieFile, } from 'cspell-dictionary';
56
56
  import { compareStats, toFileURL, urlBasename } from 'cspell-io';
57
57
  import { measurePerf } from '../../perf/index.js';
58
58
  import { isDictionaryDefinitionInlineInternal, isDictionaryFileDefinitionInternal } from '../../Settings/index.js';
@@ -257,6 +257,9 @@ async function legacyWordList(reader, filename, options) {
257
257
  if (options.kind === 'flag-words') {
258
258
  return createFlagWordsDictionary([...words], options.name, filename.toString());
259
259
  }
260
+ if (options.kind === 'suggest-words') {
261
+ return createSuggestDictionary([...words], options.name, filename.toString());
262
+ }
260
263
  return createSpellingDictionary(words, options.name, filename.toString(), applyKind(options), true);
261
264
  }
262
265
  catch (e_1) {
@@ -277,6 +280,9 @@ async function wordsPerLineWordList(reader, filename, options) {
277
280
  if (options.kind === 'flag-words') {
278
281
  return createFlagWordsDictionary([...words], options.name, filename.href);
279
282
  }
283
+ if (options.kind === 'suggest-words') {
284
+ return createSuggestDictionary([...words], options.name, filename.href);
285
+ }
280
286
  return createSpellingDictionary(words, options.name, filename.href, applyKind(options), true);
281
287
  }
282
288
  async function loadSimpleWordList(reader, filename, options) {
@@ -287,6 +293,9 @@ async function loadSimpleWordList(reader, filename, options) {
287
293
  if (options.kind === 'flag-words') {
288
294
  return createFlagWordsDictionary(lines, options.name, filename.href);
289
295
  }
296
+ if (options.kind === 'suggest-words') {
297
+ return createSuggestDictionary(lines, options.name, filename.href);
298
+ }
290
299
  return createSpellingDictionary(lines, options.name, filename.href, applyKind(options));
291
300
  }
292
301
  catch (e_2) {
@@ -305,6 +314,9 @@ async function loadTrie(reader, filename, options) {
305
314
  if (options.kind === 'flag-words') {
306
315
  return createFlagWordsDictionaryFromTrieFile(content, options.name, filename.href);
307
316
  }
317
+ if (options.kind === 'suggest-words') {
318
+ return createSuggestDictionaryFromTrieFile(content, options.name, filename.href);
319
+ }
308
320
  return createSpellingDictionaryFromTrieFile(content, options.name, filename.href, applyKind(options));
309
321
  }
310
322
  catch (e_3) {
@@ -317,7 +329,8 @@ async function loadTrie(reader, filename, options) {
317
329
  }
318
330
  /**
319
331
  * Apply the effect of `kind` on the options passed to a normal `words` dictionary loader.
320
- * `flag-words` is handled by the callers directly since it uses a different dictionary implementation.
332
+ * `flag-words` and `suggest-words` are handled by the callers directly since they use a different
333
+ * dictionary implementation.
321
334
  */
322
335
  function applyKind(options) {
323
336
  return options.kind === 'ignore-words' && !options.noSuggest ? { ...options, noSuggest: true } : options;
@@ -2,14 +2,10 @@ import { opConcatMap, opMap, pipe } from '@cspell/cspell-pipe/sync';
2
2
  import { binarySearch } from './search.js';
3
3
  import { regExAccents, regExAllLower, regExAllUpper, regExFirstUpper, regExIgnoreCharacters, regExpCamelCaseWordBreaksWithEnglishSuffix, regExWords, regExWordsAndDigits, } from './textRegex.js';
4
4
  import { toUri } from './Uri.js';
5
- import { scanMap } from './util.js';
6
5
  export { stringToRegExp } from './textRegex.js';
7
6
  // CSpell:ignore ings ning gimuy tsmerge
8
7
  export function splitCamelCaseWordWithOffset(wo) {
9
- return splitCamelCaseWord(wo.text).map(scanMap((last, text) => ({ text, offset: last.offset + last.text.length }), {
10
- text: '',
11
- offset: wo.offset,
12
- }));
8
+ return splitWordWithOffset(wo, regExpCamelCaseWordBreaksWithEnglishSuffix);
13
9
  }
14
10
  /**
15
11
  * Split camelCase words into an array of strings.
@@ -18,10 +14,23 @@ export function splitCamelCaseWord(word) {
18
14
  return splitWord(word, regExpCamelCaseWordBreaksWithEnglishSuffix);
19
15
  }
20
16
  export function splitWordWithOffset(wo, regExpWordBreaks) {
21
- return splitWord(wo.text, regExpWordBreaks).map(scanMap((last, text) => ({ text, offset: last.offset + last.text.length }), {
22
- text: '',
23
- offset: wo.offset,
24
- }));
17
+ const wText = wo.text;
18
+ const absOffset = wo.offset;
19
+ const words = [];
20
+ let lastRelOffset = 0;
21
+ const r = new RegExp(regExpWordBreaks);
22
+ for (const m of wText.matchAll(r)) {
23
+ const text = wText.slice(lastRelOffset, m.index);
24
+ const offset = absOffset + lastRelOffset;
25
+ lastRelOffset = m.index + m[0].length;
26
+ words.push({ text, offset });
27
+ }
28
+ if (lastRelOffset < wText.length) {
29
+ const text = wText.slice(lastRelOffset);
30
+ const offset = absOffset + lastRelOffset;
31
+ words.push({ text, offset });
32
+ }
33
+ return words;
25
34
  }
26
35
  /**
27
36
  * Split camelCase words into an array of strings.
@@ -2,7 +2,7 @@
2
2
  export const regExUpperSOrIng = /([\p{Lu}\p{M}]+(?:\\?['’])?(?:s|ing|ies|es|ings|ed|ning))(?!\p{Ll})/gu;
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
- export const regExpCamelCaseWordBreaksWithEnglishSuffix = /(?<=\p{Ll}\p{M}?)(?=\p{Lu})|(?<=\p{Lu}\p{M}?)(?=\p{Lu}\p{M}?\p{Ll})(?!\p{Lu}\p{M}?(?:s|ing|ies|es|ings|ed|ning)(?!\p{Ll}))/gu;
5
+ export const regExpCamelCaseWordBreaksWithEnglishSuffix = /(?<=\p{Ll}\p{M}?)(?=\p{Lu})|(?<=\p{Lu}\p{M}?)(?=\p{Lu}\p{M}?\p{Ll})(?!\p{Lu}\p{M}?(?:s|ing|ies|es|ings|ed|ning)(?!\p{Ll}))|\u00AD/gu;
6
6
  export const regExpCamelCaseWordBreaks_NOT_USED = /(?<=\p{Ll}\p{M}?)(?=\p{Lu})|(?<=\p{Lu}\p{M}?)(?=\p{Lu}\p{M}?\p{Ll})/gu;
7
7
  export const regExpAllPossibleWordBreaks_NOT_USED = /(?<=\p{Ll}\p{M}?)(?=\p{Lu})|(?<=\p{Lu}\p{M}?)(?=\p{Lu}\p{M}?\p{Ll})|(?<=\p{Lu}\p{M}?\p{Lu}\p{M}?)(?=\p{Ll})|(?<=\p{L}\p{M}?)(?=\P{L})|(?<=\P{L})(?=\p{L})/gu;
8
8
  export const regExWords = /\p{L}\p{M}?(?:(?:\\?['’])?\p{L}\p{M}?)*/gu;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "provenance": true
6
6
  },
7
- "version": "10.3.0-alpha.0",
7
+ "version": "10.3.1-alpha.0",
8
8
  "description": "A library of useful functions used across various cspell tools.",
9
9
  "type": "module",
10
10
  "sideEffects": false,
@@ -75,22 +75,22 @@
75
75
  },
76
76
  "homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-lib#readme",
77
77
  "dependencies": {
78
- "@cspell/cspell-bundled-dicts": "10.3.0-alpha.0",
79
- "@cspell/cspell-performance-monitor": "10.3.0-alpha.0",
80
- "@cspell/cspell-pipe": "10.3.0-alpha.0",
81
- "@cspell/cspell-resolver": "10.3.0-alpha.0",
82
- "@cspell/cspell-types": "10.3.0-alpha.0",
83
- "@cspell/dynamic-import": "10.3.0-alpha.0",
84
- "@cspell/filetypes": "10.3.0-alpha.0",
85
- "@cspell/rpc": "10.3.0-alpha.0",
86
- "@cspell/strong-weak-map": "10.3.0-alpha.0",
87
- "@cspell/url": "10.3.0-alpha.0",
88
- "cspell-config-lib": "10.3.0-alpha.0",
89
- "cspell-dictionary": "10.3.0-alpha.0",
90
- "cspell-glob": "10.3.0-alpha.0",
91
- "cspell-grammar": "10.3.0-alpha.0",
92
- "cspell-io": "10.3.0-alpha.0",
93
- "cspell-trie-lib": "10.3.0-alpha.0",
78
+ "@cspell/cspell-bundled-dicts": "10.3.1-alpha.0",
79
+ "@cspell/cspell-performance-monitor": "10.3.1-alpha.0",
80
+ "@cspell/cspell-pipe": "10.3.1-alpha.0",
81
+ "@cspell/cspell-resolver": "10.3.1-alpha.0",
82
+ "@cspell/cspell-types": "10.3.1-alpha.0",
83
+ "@cspell/dynamic-import": "10.3.1-alpha.0",
84
+ "@cspell/filetypes": "10.3.1-alpha.0",
85
+ "@cspell/rpc": "10.3.1-alpha.0",
86
+ "@cspell/strong-weak-map": "10.3.1-alpha.0",
87
+ "@cspell/url": "10.3.1-alpha.0",
88
+ "cspell-config-lib": "10.3.1-alpha.0",
89
+ "cspell-dictionary": "10.3.1-alpha.0",
90
+ "cspell-glob": "10.3.1-alpha.0",
91
+ "cspell-grammar": "10.3.1-alpha.0",
92
+ "cspell-io": "10.3.1-alpha.0",
93
+ "cspell-trie-lib": "10.3.1-alpha.0",
94
94
  "env-paths": "^4.0.0",
95
95
  "gensequence": "^8.0.8",
96
96
  "import-fresh": "^4.0.0",
@@ -103,7 +103,7 @@
103
103
  "node": ">=22.18.0"
104
104
  },
105
105
  "devDependencies": {
106
- "@cspell/cspell-tools": "10.3.0-alpha.0",
106
+ "@cspell/cspell-tools": "10.3.1-alpha.0",
107
107
  "@cspell/dict-cpp": "^7.1.0",
108
108
  "@cspell/dict-csharp": "^4.0.8",
109
109
  "@cspell/dict-css": "^4.1.2",
@@ -123,5 +123,5 @@
123
123
  "lorem-ipsum": "^3.0.0",
124
124
  "perf-insight": "^2.0.1"
125
125
  },
126
- "gitHead": "39297075c7a4946feb1a4f0a509e329cfb0b4f11"
126
+ "gitHead": "1fee574fa870bffd6296aef8a9c68115b9589933"
127
127
  }