Skip to content

Commit

Permalink
fix: some letters have multiple char codes.
Browse files Browse the repository at this point in the history
fixes #6574
  • Loading branch information
Jason3S committed Nov 27, 2024
1 parent f13424f commit 89f51a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ describe('lineValidatorFactory', () => {
word | expected
${'one'} | ${[]}
${'three etc.'} | ${[]}
${'three etc. π€€πƒ˜'} | ${[]}

Check warning on line 14 in packages/cspell-lib/src/lib/textValidation/lineValidatorFactory.test.ts

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (π€€πƒ˜)
${'flip-flop'} | ${[oc({ text: 'flip-flop', isFlagged: true })]}
${'one flip-flop.'} | ${[oc({ text: 'flip-flop', isFlagged: true })]}
${'one two three etc'} | ${[oc({ text: 'etc' })]}
${'three four five one'} | ${[oc({ text: 'five' })]}
${'lion'} | ${[oc({ text: 'lion', suggestionsEx: [oc({ word: 'tiger', isPreferred: true })] })]}
`('textValidatorFactory', ({ word, expected }) => {
const dict = getDict();
const tv = textValidatorFactory(dict, { ignoreCase: true, minWordLength: 1 });
const tv = textValidatorFactory(dict, { ignoreCase: true, minWordLength: 3 });
const r = [...tv.validate({ text: word, range: [10, 10 + word.length] })];
expect(r).toEqual(expected);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function lineValidatorFactory(sDict: SpellingDictionary, options: Validat
const line = lineSegment.line;

function isWordTooShort(word: TextOffsetRO, ignoreSuffix = false): boolean {
if (word.text.length >= minWordLength) return false;
if (word.text.length >= minWordLength * 2 || [...word.text].length >= minWordLength) return false;
const offset = word.offset - line.offset;
assert.equal(line.text.slice(offset, offset + word.text.length), word.text);
const prefix = [...line.text.slice(Math.max(0, offset - 2), offset)];
Expand Down

0 comments on commit 89f51a1

Please sign in to comment.