Skip to content

fix: keep written case in legacy compound checks - #9544

Open
mvanhorn wants to merge 2 commits into
streetsidesoftware:mainfrom
mvanhorn:fix/9452-usecompounds-case
Open

mvanhorn wants to merge 2 commits into
streetsidesoftware:mainfrom
mvanhorn:fix/9452-usecompounds-case

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 5, 2026

Copy link
Copy Markdown

Motivation

With legacy compound splitting and case-sensitive checking, a word whose capitals are wrong is still accepted when the lower-case spelling splits into dictionary words. A form such as eRRorcODE is treated as correct because it is reduced to error plus code.

After the word as written fails the compound lookup, the search is repeated on alternate forms, including the lower-case form. That second pass no longer has the capitals from the original word, so any mixed-case spelling whose lower-case pieces are in the dictionary is accepted.

Summary

Alternate-form compound retries now run only when case is ignored, the dictionary is not case-sensitive, or the whole word is upper case. Mixed-case words are judged from the spelling as written, while an all-caps word such as ERRORCODE can still match through its lower-case form. A dictionary test covers the mixed-case rejections and the all-caps, lower-case, and ignore-case cases that still pass.

How it was tested

  • npx --no-install vitest run src/SpellingDictionary/SpellingDictionary.test.ts passed all 86 tests in that file.
  • node_modules/.bin/prettier -c website/ --check packages/cspell-dictionary/src/SpellingDictionary/SpellingDictionary.test.ts packages/cspell-dictionary/src/SpellingDictionary/SpellingDictionaryFromTrie.ts reported that the matched files match Prettier style.
  • The tests in packages/cspell-dictionary/src/SpellingDictionary/SpellingDictionary.test.ts fail without the fix in the cspell SpellingDictionaryFromTrie change (checked by reverting the source changes).

Fixes #9452

Alternate-form compound retries now run only when case is ignored, the
dictionary is not case-sensitive, or the whole word is upper case.
Mixed-case words are judged from the spelling as written, while an
all-caps word such as ERRORCODE can still match through its lower-case
form. A dictionary test covers the mixed-case rejections and the
all-caps, lower-case, and ignore-case cases that still pass.

Fixes streetsidesoftware#9452
Resolve the import conflict in SpellingDictionaryFromTrie.ts: main moved
repMap out of this file, so only the isUpperCase import is kept.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: With useCompounds, words with wrong capitals pass when case matters

1 participant