-
Notifications
You must be signed in to change notification settings - Fork 257
TeX-faithful brace grouping (MTMathGroup) — fix #177 #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ca89238
[item 1] Add MTMathGroup atom (kMTMathAtomOrdGroup) for brace groups
kostub 6ec1a82
[item 2] Wrap main-list {…} as MTMathGroup in the parser
kostub b7a705a
[item 3] Render MTMathGroup in the typesetter (fix #177 style leak)
kostub f99517a
Fix stale _groupWasTransformedByStopCommand leaking into enclosing group
kostub adbe7f9
Address review #247: fix prevAtom in \over-transformed path; drop red…
kostub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two critical issues in this block:
prevAtomis not updated: In thetransformedpath,sublistis appended tolistand the loop continues, butprevAtomis never updated to the last atom ofsublist. This causes any subsequent scripts (like^2) or operators to attach to the wrong atom (or create a new empty atom) instead of the transformed fraction._groupWasTransformedByStopCommandleak: Since_groupWasTransformedByStopCommandis a shared instance variable, when a nested group is transformed (e.g.,{a {b \over c}}), the flag remainsYESeven after returning to the parent group. This causes grandparent groups to also skip wrapping inMTMathGroup. Resetting it toNOimmediately after reading prevents this leak.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified both points against the current head (adbe7f9).
1.
prevAtomnot updated — real bug, fixed in adbe7f9. Confirmed by reproducing it:{a \over b}^2serialized as\frac{a}{b}{}^{2}— the^2attached to a spurious emptyOrdinstead of the fraction, because thetransformedbranch appendedsublistwithout settingprevAtom(the^/_/'branches all key offprevAtom). RestoredprevAtom = [sublist.atoms lastObject]in that path, matching the pre-grouping behavior and the shared append path below. Regression testtestScriptAfterOverTransformedGroupAttachesToFractionadded.2.
_groupWasTransformedByStopCommandleak — already fixed in f99517a. This review was filed againstb7a705a(3rd commit). The 4th commitf99517a("Fix stale _groupWasTransformedByStopCommand leaking into enclosing group") landed afterward and does exactly the read-and-clear suggested here —BOOL transformed = _groupWasTransformedByStopCommand; _groupWasTransformedByStopCommand = NO;at MTMathListBuilder.m:244–245, read and cleared in the{…}branch before any fallthrough. The{{a \over b}\scriptstyle c}zleak variant is covered bytestBraceGroupingAroundOverTransform. No further change.