fix(layout): guard the default tab-stop grid against a non-positive interval - #3947
Open
leonidkuznetsov18 wants to merge 1 commit into
Open
Conversation
…nterval A DOCX whose word/settings.xml carries <w:defaultTabStop w:val="0"/> froze the main thread forever: computeTabStops generates the automatic tab-stop grid with `pos += defaultTabInterval` toward a fixed limit, so an interval of 0 (or a negative one) never advances and the loop never terminates. onReady/onException never fire and the page pegs the CPU until the tab is killed. The grid is pre-computed for every measured paragraph, so any document with text content triggers it — no tab characters required. Word writes defaultTabStop 0 when a user sets the default tab interval to 0, opens such documents fine, and simply generates no automatic tab stops. Do the same: skip the default grid for a non-positive (or non-finite) interval, keeping explicit stops and the implicit indent-driven stops intact. Mirrors the existing guard in word-layout's computeTabStops. Fixes superdoc#3944 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
What
A DOCX whose
word/settings.xmlcarries<w:defaultTabStop w:val="0"/>froze the main thread forever:onReady/onExceptionnever fired and the tab pegged the CPU until killed (#3944).computeTabStops(packages/layout-engine/contracts/src/engines/tabs.ts) generates the automatic tab-stop grid withpos += defaultTabIntervaltoward a fixed limit, so an interval of0(or a negative one) never advances and the loop never terminates. BothbuildTabStopsPxcallers (measuring/domandlayout-bridge/remeasure) pass the document value throughtabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS, and??doesn't catch0. The grid is pre-computed for every measured paragraph, which is why any document with text content triggers it — no tab characters required (an empty<w:p/>escapes via the simple-empty-paragraph fast path, matching the repro matrix in the issue).Fix
Skip the default grid for a non-positive (or non-finite) interval, keeping explicit stops and the implicit indent-driven stops intact. Word writes
defaultTabStop0 when a user sets the default tab interval to 0, opens such documents fine, and simply generates no automatic tab stops — so "no grid" is the Word-faithful behavior, and it mirrors the existing guard inword-layout's owncomputeTabStops(packages/word-layout/src/tab-layout.ts).Guarding this single choke point covers both callers; it is the only
+= intervalloop over the document value in the layout engine.Testing
tabs.test.tsfor interval0(no default grid, terminates) and a negative interval (explicit stops preserved, no default grid). Without the guard the first test hangs the runner — verified by stashing the fix: the suite ran into a 3-minute wall timeout exactly as described in the issue.packages/layout-engine/contracts: 492/492 pass.measuring/dom529/529,layout-bridge1653/1653 pass.Fixes #3944