-
Notifications
You must be signed in to change notification settings - Fork 105
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
SourceSpan support #123
SourceSpan support #123
Conversation
b12d986
to
d33430b
Compare
Well, I've started removing Our code will become a mess with slices of Looks like we should return back to the design board. Probably we will need that Because, well, current problem is that we cannot get cheap class copying in C#, so we have to implement this |
@ForNeVeR As long as there are no many-to-one or one-to-many references (from memory I don't think so), then converting everything to value types (i.e. structs) would seem to make sense to me. You get efficient copying for free then. |
Yeah, working on it in a separate branch. We'll see what else we can do. I have some other ideas. |
This commit intentionally won't compile. # Conflicts: # src/WpfMath/Atom.cs # src/WpfMath/CharSymbol.cs # src/WpfMath/DummyAtom.cs # src/WpfMath/OverUnderDelimiter.cs # src/WpfMath/RowAtom.cs # src/WpfMath/SpaceAtom.cs # src/WpfMath/TexFormulaParser.cs # src/WpfMath/UnderOverAtom.cs
Now I'm not sure about that. Currently, all of our We could mark only the root of the Hereby I revoke my requirement about adding |
Also, we have some bugs here. @yamamoto-reki made the selected blocks to highlight themselves in the example project. E.g.
In my PR, it doesn't highlight some blocks and sometimes behaves weird: Before merging, we'll need to fix that weirdness and make sure everything works well. |
@@ -75,6 +94,18 @@ public ControlTemplate ErrorTemplate | |||
"ErrorTemplate", typeof(ControlTemplate), typeof(FormulaControl), | |||
new PropertyMetadata(new ControlTemplate())); | |||
|
|||
public static readonly DependencyProperty SelectionStartProperty = DependencyProperty.Register( | |||
"SelectionStart", typeof(int), typeof(FormulaControl), |
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.
Don't forget to use nameof
here!
@@ -49,18 +49,23 @@ public TexRenderer GetRenderer(TexStyle style, double scale, string systemTextFo | |||
return new TexRenderer(CreateBox(environment), scale); | |||
} | |||
|
|||
public void Add(TexFormula formula) | |||
public void Add(TexFormula formula, SourceSpan source = null) |
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.
The binary compatibility has been broken here, unfortunately (the source compatibility was preserved). We could fix that. Should we?
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.
Don't think so. Hopefully nobody uses that API. And we're still in API-breaking period of our semver (0.x
versions). And it's notoriously hard if not impossible to keep full source+binary compatibility when method overloads are involved.
@@ -1,341 +1,339 @@ | |||
using System; |
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.
Previously this file had CRLF
and now it has LF
(it was replaced because I renamed it to match the class name). I think that's alright.
Please check the online diff with ?w=1
appended to the page URL to see the real changes (it will ignore the whitespace diff): https://github.com/ForNeVeR/wpf-math/pull/123/files?w=1#diff-e81f0c498a5c8d83d49d999c0375f718
Alright, it's ready for review, guys. @yamamoto-reki could you also please take a look? My next step will be to review (and probably merge) the remaining changes ( |
|
||
// TODO[F]: Review the cases where the formula gets constructed from this.Formula.RootAtom wrapped in something | ||
// (e.g. SetFixedTypes): in these cases, it looks like we should clean the SourceSpan inside of a formula and | ||
// set it for the new root atom only? |
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.
Please file an issue about that!
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.
See #132.
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.
OK, that's very big PR...
🐐
Great job! |
Thanks for the review! |
Good job with this, @ForNeVeR! Not a small task, but looks like really important work going forwards. |
Closes #115.
This is a rebased version of PR #116. I will be fixing the tests here and polishing the changes.
TODO
BoxWalker
andFormulaUtils
Atom.Copy
in favor ofAtomWithSource
AddI decided to not do thatBox.SourceAtom
, dropBox.Source
StringSpan
intoSourceSpan
SourceSpan
s