Prefer logic on the SupSub node rather than separate logic on SubscriptCommand and SuperscriptCommand #327
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.
Mathquill had separate
SubscriptCommand
andSuperscriptCommand
node classes, which were subclasses ofSupSub
.Before this PR, it was possible to create a
SuperscriptCommand
that only contained a subscript with the following steps:x^2
x_1^2
x_1
.(The reverse is possible as well; you could make
x^2
be aSubscriptCommand
by switching superscript and subscript in the steps).This caused an issue when you typed
)
after the resultingx_1
because it duplicated the subscript to the superscript, givingx_1^1
. (presumably infinalizeTree
). A simple fix for that would be to do change the prototype to aSubscriptCommand
, but instead this PR removes theSuperscriptCommand
andSubscriptCommand
classes in favor of using thesupsub
property on theSupSub
class.While merging the
SuperscriptCommand
andSubscriptCommand
methods intoSupSub
, I found and fixed a couple more problems:undefined
show up for a SupSub with both a superscript and a subscript. E.g. forx_1^y
it said"x" Subscript, 1 , Baseline "y" undefined
. Now, it says"x" Subscript, 1 , Baseline Superscript, "y" , Baseline
.x_1^2
it could say"x" squared
, forgetting the subscript.SuperscriptCommand
, i.e. you typed the superscript first before the subscript.