Repository navigation
Conversation
|
Thank you. Looks like my over aggressive comment detector kicked in. |
There was a problem hiding this comment.
🟢 Approval recommended
The fix is a small, correctly-scoped regex change in one function, verified against every new test case and relevant edge cases, with adequate accompanying test coverage.
No open issues 🎉
What changed in this PR
This PR fixes a bug in cspell's in-document directive parsing where a cspell:locale / cspell:language directive wrapped in a comment (e.g. <!-- cspell:locale en --> or /* cspell:locale en */) treated the comment's closing marker (--> or */) as an additional locale. With useIntlWordSegmentation enabled, that stray token caused RangeError: Invalid language tag and failed the whole file. The fix strips a trailing HTML/block comment closer in parseLocale before splitting the locale list, addressing issue #9480.
Changes:
- In
parseLocale, remove a trailing-->-style or*/-style comment closer (with surrounding whitespace) before trimming and splitting the locale value. - Add a parameterized test verifying locale/language directives ignore comment closers across HTML and block-comment forms, including multi-locale and dashed-locale cases.
| File | Description |
|---|---|
packages/cspell-lib/src/lib/Settings/InDocSettings.ts |
Strips a trailing comment closing marker from a locale directive so it is not parsed as an extra locale. |
packages/cspell-lib/src/lib/Settings/InDocSettings.test.ts |
Adds tests covering locale/language directives with HTML and block comment closers. |
Review effort: Balanced
Summary
cspell:locale(orcspell:language) directive no longer treats the closing-->of an HTML comment, or*/of a block comment, as an extra locale.<!-- cspell:locale en -->made files fail withRangeError: Invalid language tagwhenuseIntlWordSegmentationwas on.Fixes #9480