cspell-dictionary 9.0.1 → 9.0.2

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.
@@ -1,4 +1,7 @@
1
1
  import type { SpellingDictionary } from './SpellingDictionary.js';
2
+ export interface CreateIgnoreWordsDictionaryOptions {
3
+ supportNonStrictSearches?: boolean | undefined;
4
+ }
2
5
  /**
3
6
  * Create a dictionary where all words are to be ignored.
4
7
  * Ignored words override forbidden words.
@@ -7,5 +10,5 @@ import type { SpellingDictionary } from './SpellingDictionary.js';
7
10
  * @param source - dictionary source
8
11
  * @returns
9
12
  */
10
- export declare function createIgnoreWordsDictionary(wordList: readonly string[], name: string, source: string): SpellingDictionary;
13
+ export declare function createIgnoreWordsDictionary(wordList: readonly string[], name: string, source: string, options?: CreateIgnoreWordsDictionaryOptions): SpellingDictionary;
11
14
  //# sourceMappingURL=IgnoreWordsDictionary.d.ts.map
@@ -82,10 +82,11 @@ const createCache = createAutoResolveWeakCache();
82
82
  * @param source - dictionary source
83
83
  * @returns
84
84
  */
85
- export function createIgnoreWordsDictionary(wordList, name, source) {
85
+ export function createIgnoreWordsDictionary(wordList, name, source, options) {
86
86
  return createCache.get(wordList, () => {
87
87
  const testSpecialCharacters = /[*+]/;
88
- const words = [...parseDictionaryLines(wordList, { stripCaseAndAccents: true })].map((w) => w.normalize(NormalizeForm));
88
+ const parseOptions = { stripCaseAndAccents: options?.supportNonStrictSearches ?? true };
89
+ const words = [...parseDictionaryLines(wordList, parseOptions)].map((w) => w.normalize(NormalizeForm));
89
90
  const hasSpecial = words.some((word) => testSpecialCharacters.test(word));
90
91
  if (hasSpecial) {
91
92
  return createSpellingDictionary(words, name, source, {
@@ -66,12 +66,12 @@ export interface SpellingDictionaryOptions {
66
66
  *
67
67
  * @default true
68
68
  */
69
- supportNonStrictSearches?: boolean;
69
+ supportNonStrictSearches?: boolean | undefined;
70
70
  /**
71
71
  * Turns on legacy word compounds.
72
72
  * @deprecated
73
73
  */
74
- useCompounds?: boolean;
74
+ useCompounds?: boolean | undefined;
75
75
  /**
76
76
  * Optional WeightMap used to improve suggestions.
77
77
  */
@@ -56,8 +56,10 @@ class SuggestDictionaryImpl {
56
56
  isSuggestedWord(word, ignoreCaseAndAccents = defaults.isForbiddenIgnoreCaseAndAccents) {
57
57
  if (this.suggestions.has(word))
58
58
  return true;
59
+ if (!ignoreCaseAndAccents)
60
+ return false;
59
61
  const lcWord = word.toLowerCase();
60
- return ignoreCaseAndAccents && (this.suggestions.has(lcWord) || this.suggestionsLower.has(lcWord));
62
+ return this.suggestions.has(lcWord) || this.suggestionsLower.has(lcWord);
61
63
  }
62
64
  suggest(word) {
63
65
  return this.getPreferredSuggestions(word);
@@ -8,11 +8,12 @@ import { createSuggestDictionary } from './SuggestDictionary.js';
8
8
  const cache = createAutoResolveWeakCache();
9
9
  export function createInlineSpellingDictionary(inlineDict, source) {
10
10
  return cache.get(inlineDict, () => {
11
- const { words, flagWords, ignoreWords, suggestWords, name } = inlineDict;
11
+ const { words, flagWords, ignoreWords, suggestWords, name, supportNonStrictSearches } = inlineDict;
12
+ const options = { supportNonStrictSearches };
12
13
  const dictSources = [
13
14
  words && createSpellingDictionary(words, name + '-words', source, inlineDict),
14
15
  flagWords && createFlagWordsDictionary(flagWords, name + '-flag-words', source),
15
- ignoreWords && createIgnoreWordsDictionary(ignoreWords, name + '-ignore-words', source),
16
+ ignoreWords && createIgnoreWordsDictionary(ignoreWords, name + '-ignore-words', source, options),
16
17
  suggestWords && createSuggestDictionary(suggestWords, name + '-suggest', source),
17
18
  ].filter(isDefined);
18
19
  return createCollection(dictSources, name, source);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "provenance": true
6
6
  },
7
- "version": "9.0.1",
7
+ "version": "9.0.2",
8
8
  "description": "A spelling dictionary library useful for checking words and getting suggestions.",
9
9
  "type": "module",
10
10
  "sideEffects": false,
@@ -54,14 +54,14 @@
54
54
  "node": ">=20"
55
55
  },
56
56
  "dependencies": {
57
- "@cspell/cspell-pipe": "9.0.1",
58
- "@cspell/cspell-types": "9.0.1",
59
- "cspell-trie-lib": "9.0.1",
57
+ "@cspell/cspell-pipe": "9.0.2",
58
+ "@cspell/cspell-types": "9.0.2",
59
+ "cspell-trie-lib": "9.0.2",
60
60
  "fast-equals": "^5.2.2"
61
61
  },
62
62
  "devDependencies": {
63
63
  "gensequence": "^7.0.0",
64
64
  "lorem-ipsum": "^2.0.8"
65
65
  },
66
- "gitHead": "bdfabd3686aac9827f3af0ceb4aa74947b5f9d60"
66
+ "gitHead": "39dbd9ab9b8943a023d9eda7f65f81e822f939b5"
67
67
  }