Skip to content

Commit

Permalink
fix: cspell-tools - compounds (#6506)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Nov 7, 2024
1 parent 59899a7 commit 649bedf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('', () => {
${'HELLO|*hello*|*HELLO*'} | ${['*hello*']}
${'HELLO|*HELLO*'} | ${['*HELLO*']}
${'Hello|*Hello*'} | ${['*Hello*']}
${'hello|+hello+'} | ${['hello', '+hello+']}
${'hello|+hello+'} | ${['*hello*' /* this is on purpose */]}
${'hello|hello+'} | ${['hello*']}
${'hello|+hello'} | ${['*hello']}
${'hello|hello+|+hello|+hello+'} | ${['*hello*']}
Expand Down
6 changes: 5 additions & 1 deletion packages/cspell-tools/src/compiler/wordListCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ function applyFlags(word: string, flags: Flags): string[] {
if (flags === (Flags.none | Flags.sfx)) return ['*' + word];
if (flags === (Flags.none | Flags.pfx)) return [word + '*'];
if (flags === (Flags.none | Flags.pfx | Flags.sfx)) return [word + '*', '*' + word];
if (flags === (Flags.none | Flags.both)) return [word, '+' + word + '+'];
if (flags === (Flags.none | Flags.both)) {
// the "correct" answer is [word, '+' + word + '+']
// but practically it makes sense to allow all combinations.
return ['*' + word + '*'];
}
if (flags === (Flags.none | Flags.both | Flags.sfx)) return [word, '+' + word + '*'];
if (flags === (Flags.none | Flags.both | Flags.pfx)) return [word, '*' + word + '+'];
if (flags === (Flags.both | Flags.pfx)) return ['*' + word + '+'];
Expand Down

0 comments on commit 649bedf

Please sign in to comment.