Skip to content

Commit

Permalink
fix: (cspell-tools) Delay splitting _ till later (#4309)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Mar 13, 2023
1 parent e524c61 commit 0e517d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/cspell-tools/src/compiler/legacyLineToWords.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import { opFilter, pipe } from '@cspell/cspell-pipe/sync';

import { resolvePathToFixture } from '../test/TestHelper';
import { createAllowedSplitWordsFromFiles } from './createWordsCollection';
import { createAllowedSplitWords } from './createWordsCollection';
import { legacyLineToWords } from './legacyLineToWords';
import { defaultAllowedSplitWords } from './WordsCollection';

Expand Down Expand Up @@ -44,10 +43,11 @@ describe('Validate legacyLineToWords', () => {
${'well-educated'} | ${['well', 'educated']}
${'CURLcode'} | ${['CURLcode']}
${'RedGreen'} | ${['red', 'green']}
${'kDNSServiceErr_BadSig'} | ${['kDNSServiceErr', 'BadSig']}
${'apd_get_active_symbols'} | ${['apd', 'get', 'active', 'symbols']}
${'kDNSServiceErr_BadSig'} | ${['kDNSServiceErr_BadSig']}
${'apd_get_active_symbols'} | ${['apd_get_active_symbols']}
${'RED_GREEN'} | ${['red', 'green']}
`('legacy splitting lines $line', async ({ line, expectedResult }: { line: string; expectedResult: string[] }) => {
const allowed = await createAllowedSplitWordsFromFiles([resolvePathToFixture('dicts/colors.trie')]);
const allowed = await createAllowedSplitWords(['red', 'green']);
expect([...pipe(legacyLineToWords(line, false, allowed), opFilter(distinct()))]).toEqual(expectedResult);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-tools/src/compiler/legacyLineToWords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { opConcatMap, opFilter, opMap, pipe } from '@cspell/cspell-pipe/sync';
import { regExpSpaceOrDash, splitCamelCaseIfAllowed } from './splitCamelCaseIfAllowed';
import type { AllowedSplitWordsCollection } from './WordsCollection';

const regNonWord = /[^\p{L}\p{M}' \d]+/giu;
const regNonWord = /[^\p{L}\p{M}' _\d]+/giu;
const regExpRepeatChars = /(.)\1{5}/i;

export function legacyLineToWords(
Expand Down

0 comments on commit 0e517d1

Please sign in to comment.