Conversation
|
Yes. |
|
Getting errors I'm having trouble diagnosing. Inputs: 1, power, 2 Debug code gives: I have the feeling it's to do with mutability and the static void InsertAtAtomIndexAndAdvance(this MathList self, int atomIndex, MathAtom atom, ref MathListIndex advanceIndependently of getting this PR working, it's good to remove the Once this PR goes in and the immutable change we will have a clean base to work on #117 . Any thoughts @Happypig375 ? |
| # https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#c-formatting-settings | ||
| csharp_new_line_before_catch = false | ||
| csharp_new_line_before_else = false | ||
| #csharp_new_line_before_else = false |
| csharp_new_line_before_members_in_object_initializers = false | ||
| csharp_new_line_before_members_in_anonymous_types = false | ||
| csharp_new_line_before_open_brace = none | ||
| #csharp_new_line_before_open_brace = none |
| case MathListSubIndexType.Superscript: | ||
| self.Atoms[index.AtomIndex].Superscript.InsertAndAdvance(ref index.SubIndex, atom, advanceType); | ||
| case (MathListSubIndexType.Superscript, MathListIndex subIndex): | ||
| self.Atoms[index.AtomIndex].Superscript.InsertAndAdvance(ref subIndex, atom, advanceType); |
There was a problem hiding this comment.
The ref now mutates the local instead of the index. Same below.
| Array.IndexOf(typeof(MathListSubIndexType).GetEnumValues(), index.SubIndexType) == -1 | ||
| ? $"{index.SubIndexType} is an invalid subindex type." | ||
| : $"{index.SubIndexType} not found at index {index.AtomIndex}.") { } | ||
| Array.IndexOf(typeof(MathListSubIndexType).GetEnumValues(), index.SubIndexInfo!.Value.SubIndexType) == -1 |
There was a problem hiding this comment.
Exception will appear when SubIndexInfo is null
| <packageSources> | ||
| <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> | ||
| </packageSources> | ||
| </configuration> No newline at end of file |
|
|
||
| /// <summary>Factory function to create a `MathListIndex` with no subindexes.</summary> | ||
| /// <param name="index">The index of the atom that the `MathListIndex` points at.</param> | ||
| public static MathListIndex Level0Index(int index) => new MathListIndex(index, null); |
There was a problem hiding this comment.
Can be made into a default parameter of constructor
I don't think removing refs can be independent of this PR. Currently InsertAtAtomIndexAndAdvance advances the advance parameter and now that behaviour is gone, hence test failures. |
| return self.InsertAtAtomIndexAndAdvance(atomIndex, atom, advanceType); | ||
| case (MathListSubIndexType type, MathListIndex subIndex): | ||
| switch (type) { | ||
| case MathListSubIndexType.BetweenBaseAndScripts: // TODO: finish this section |
There was a problem hiding this comment.
I don't really understand this case. The docs on BetweenBaseAndScripts has The position in the subindex is an index into the nucleus, must be 1 and I don't understand that exactly. Could you help with this part @Happypig375 ?
There was a problem hiding this comment.
The AtomIndex of the SubIndex must be 1 for SubIndexType BetweenBaseAndScripts.
There was a problem hiding this comment.
I got that far...
There was a problem hiding this comment.
In 12^3, is there a MathListIndex of 2?
There was a problem hiding this comment.
Yes. The right boundary of the whole MathList. (for insertions)
There was a problem hiding this comment.
What is the MathListIndex of 2 in 12^3?
There was a problem hiding this comment.
Yes. The right boundary of the whole MathList. (for insertions)
| Cursor position | MathListIndex |
|---|---|
| ‸12^3 | 0 |
| 1‸2^3 | 1 |
| 12‸^3 | 1, BetweenBaseAndScripts:1 |
| 12^‸3 | 1, Superscript:0 |
| 12^3‸ | 1, Superscript:1 (to the right of 3) OR 2 (to the right of the entire MathList) |
Currently MathListIndex is supposed to have a SubIndex if an only if SubIndexType <> MathListSubIndexType.None. (Can you confirm that @Happypig375 ?)
This PR brings this constraint into the type structure, removing
MathListSubIndexType.Noneand having: