Repository navigation
fix(muyajs): null-guard list block paths to prevent renderer crash (#4346) - #4359
Merged
Merged
Conversation
…4346) When a list item is mutated (Backspace through empty list, task-list <-> bullet transitions, paste empty <ul></ul>) the contentState transiently holds references to blocks whose children array is empty or whose startBlock has been removed. Three sites destructured / read fields on the resulting null: - exportMarkdown.js ul/ol case destructured block.children[0] - formatCtrl.selectionFormats destructured text from a null startBlock - backspaceCtrl.backspaceHandler read .type from a null block Add null guards at each site. Adjacent-stack reproduction guarded by packages/desktop/test/e2e/issue-4346.spec.ts (task-list -> bullet-list backspace recipe). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Website preview ready: https://pr-4359-marktext-website.ransixi.workers.dev Built from |
Contributor
|
Build artifacts for PR #4359: Run: https://github.com/marktext/marktext/actions/runs/26892918987
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
packages/desktop/test/e2e/issue-4346.spec.tsreproduces the adjacent-stack crash via task-list -> bullet-list backspace; turns red without the fix, green with itRoot cause
When a list item is mutated (Backspace through empty list, task-list <-> bullet transitions, paste empty
<ul></ul>) the contentState transiently holds references to blocks whosechildrenarray is empty or whosestartBlockhas been removed. Three sites destructured / read fields on the resulting null:packages/muyajs/lib/utils/exportMarkdown.jsul/ol case destructuredblock.children[0]-> the originally reportedCannot destructure property 'bulletMarkerOrDelimiter' of 'block2.children[0]' as it is undefinedpackages/muyajs/lib/contentState/formatCtrl.jsselectionFormatsdestructuredtextfrom a nullstartBlockpackages/muyajs/lib/contentState/backspaceCtrl.jsbackspaceHandlerread.typefrom a null blockEach site now short-circuits when its block is missing, deferring to the next selection-change cycle once state settles.
Closes
Closes #4346
Test plan
pnpm -C packages/desktop exec playwright test test/e2e/issue-4346.spec.ts-- 4/4 pass with this PR (verified red without the fix)crash-range-offset.spec.ts,crash-selection-change.spec.ts,crash-update-paragraph.spec.tspnpm run typecheckcleanGenerated with Claude Code