[lexical-code-shiki] Bug Fix: Set the unsupported syntax flag only once#8606
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
1e98fbb to
6dc017c
Compare
|
Code Review — Tater Thoughts Bobblehead (Sherry's Navi) ✅ This fix looks correct and well-reasoned. Safe to approve once CI is fully green. What I verified:
CI note: The integrity failure is the website build ( |
|
Looks like there's some kind of failure in the website build, usually that's incorrect syntax or a broken link in a jsdoc comment |
|
Follow-up Review — Tater Thoughts Bobblehead (Sherry's Navi) ✅ Updated approach looks even better than the strict-inequality fix I reviewed earlier. Safe to approve. What changed since last review:
Why this is correct:
Compared to #8607: This approach is architecturally superior — it addresses the root cause (premature state mutation) rather than applying strict-inequality guards that mask the problem. Agree with etrepum's decision to prefer this PR. Ready to approve. |
potatowagon
left a comment
There was a problem hiding this comment.
Reviewed by Navi (Tater Thoughts Bobblehead) on behalf of @potatowagon.
LGTM ✅ — Clean fix targeting the Shiki highlighter's unsupported-flag-setting logic.
What this does: Fixes the unsupported syntax flag being set incorrectly when a language isn't loaded yet. The fix reorders the logic: call loadCodeLanguage() first, check its return value — if it returns undefined (meaning the language is already loaded or isn't supported), then set isSyntaxHighlightSupported to false. This prevents the transform from redundantly setting the flag on every trigger while a language download is in flight.
What I checked:
- ✅ Logic correctness: The key insight is that
loadCodeLanguagereturns a Promise when it initiates a download, orundefinedwhen no download occurs (already loaded or unsupported). Only theundefinedcase should mark the language as unsupported. During an active download, the flag shouldn't change — it'll be set totruewhen the download completes (via the editor.update callback inside loadCodeLanguage). - ✅ JSDoc added: Good documentation on
loadCodeLanguagereturn value semantics. - ✅ Note:
inFlight = trueis still set unconditionally — this is correct because if loadCodeLanguage returns a promise OR undefined (unsupported language), the remaining highlight logic should be skipped for this transform pass. - ✅ www compat: No public API changes. Shiki-only internal fix.
- ✅ CI: All checks green (CLA signed, core-tests, e2e-tests pass).
Safe to land. Targeted fix for a code highlighting transform loop in the Shiki package.
Description
While the syntax highlighter is loading, the CodeNode transform may continuously update the state of
node.setIsSyntaxHighlightSupported(false). To fix this continuous updating, the return value from theloadCodeLanguagefunction is checked sonode.setIsSyntaxHighlightSupported(false)is called only if the language is not supportedCloses #8605
Closes #8607
Test plan
Before
Switching from prism to shiki caused an infinite transform loop while loading the language highlighting module
After
When switching from prism to shiki, the unsupported syntax flag is set only if the highlighting module did not occur