-
Notifications
You must be signed in to change notification settings - Fork 68
Delete when in a placeholder should simplify containing expression #117
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
Draft
Happypig375
wants to merge
23
commits into
master
Choose a base branch
from
issue108/DeleteInPlaceholder
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6a3d01a
Implemented for fractions, radicals and superscripts
Happypig375 9e8e435
Added tests
Happypig375 98aa35d
More tests
Happypig375 eccb0a8
Tests for Inner
Happypig375 ab4a4a7
Delete trash
Happypig375 638bd1e
Tests for delete at beginnning of script when both scripts are present
Happypig375 f6db396
Also add power counterpart for this test
Happypig375 8e2d2ca
And placeholder counterparts
Happypig375 fc58258
Deleting placeholders at the start should not eliminate scripts
Happypig375 4ec984c
More range checking
Happypig375 5616369
Merge branch 'master' into issue108/DeleteInPlaceholder in order to make
Happypig375 f018231
Remove refs on MathListIndex inputs
charlesroddie 85427c6
Move IsBeforeSubList and PreviousOrBeforeWholeList to prevent usage i…
charlesroddie 4858a68
Rename SetTo to ReplaceWith
charlesroddie 624ce67
Accepted simplification recommendations
charlesroddie bf87ef0
Merge branch 'master' into issue108/DeleteInPlaceholder
Happypig375 da9c95b
Merge branch 'issue108/DeleteInPlaceholder' of https://github.com/ver…
charlesroddie 4d2b72a
tweak wording
charlesroddie c8675a1
remove unnecessary null checks
charlesroddie ac01721
add documentation TODOs
charlesroddie 5b1ad8e
Add TODOs
charlesroddie 9e91a94
failing test is unnecessary
charlesroddie 5a764bb
add TODO
charlesroddie 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,11 +81,25 @@ public static void InsertAndAdvance(this MathList self, ref MathListIndex index, | |
throw new SubIndexTypeMismatchException(index); | ||
} | ||
} | ||
|
||
public static MathListIndex? PreviousOrBeforeWholeList(MathListIndex index) { | ||
return | ||
index.SubIndexType switch | ||
{ | ||
MathListSubIndexType.None => index.AtomIndex > -1 ? MathListIndex.Level0Index(index.AtomIndex - 1) : null, | ||
_ => | ||
(index.SubIndex == null) ? null : | ||
PreviousOrBeforeWholeList(index.SubIndex) is MathListIndex prevSubIndex | ||
? MathListIndex.IndexAtLocation(index.AtomIndex, index.SubIndexType, prevSubIndex) : null, | ||
}; | ||
} | ||
public static void RemoveAt(this MathList self, MathListIndex index) { | ||
static bool IsBeforeSubList(MathListIndex index) { | ||
return (index.SubIndex != null && index.SubIndex.AtomIndex == -1) && index.SubIndexType == MathListSubIndexType.None; | ||
} | ||
|
||
void RemoveAtInnerList<TAtom>(TAtom atom, int innerListIndex) where TAtom : MathAtom, IMathListContainer { | ||
if (index.SubIndex is null) throw new InvalidCodePathException($"{nameof(index.SubIndex)} should exist"); | ||
if (index.IsBeforeSubList) { | ||
if (IsBeforeSubList(index)) { | ||
index.SetTo( | ||
index.LevelDown() | ||
?? throw new InvalidCodePathException($"{nameof(index.SubIndex)} is not null but {nameof(index.LevelDown)} is null")); | ||
|
@@ -112,7 +126,7 @@ void RemoveAtInnerList<TAtom>(TAtom atom, int innerListIndex) where TAtom : Math | |
void RemoveAtInnerScript(ref MathListIndex index, MathAtom atom, bool superscript) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for this function |
||
if (index.SubIndex is null) throw new InvalidCodePathException($"{nameof(index.SubIndex)} should exist"); | ||
var script = superscript ? atom.Superscript : atom.Subscript; | ||
if (index.IsBeforeSubList) { | ||
if (IsBeforeSubList(index)) { | ||
index.SetTo( | ||
index.LevelDown() | ||
?? throw new InvalidCodePathException($"{nameof(index.SubIndex)} is not null but {nameof(index.LevelDown)} is null")); | ||
|
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
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.
Should this be an extension method?
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.
Perhaps. I tried to move it inside the Delete method because the xml comment said "only use from Delete..." but it also needed to be used in DeleteBackwards in MathKeyboard.