ForNeVeR / xaml-math

A collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and Avalonia XAML-based frameworks
MIT License
641 stars 102 forks source link

Crash on typing `\left\{\matrix{}\right\}` #409

Closed ForNeVeR closed 1 year ago

ForNeVeR commented 1 year ago

While typing \left\{\matrix{}\right\} today, I've caught an example app crash on WPF :(

The exception is:

System.InvalidOperationException: Sequence contains no elements
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.Max[TSource](IEnumerable`1 source, Func`2 selector)
   at XamlMath.Atoms.MatrixAtom.CreateBoxCore(TexEnvironment environment) in G:\Projects\xaml-math\src\XamlMath.Shared\Atoms\MatrixAtom.cs:line 59
   at XamlMath.Atoms.Atom.CreateBox(TexEnvironment environment) in G:\Projects\xaml-math\src\XamlMath.Shared\Atoms\Atom.cs:line 12
   at XamlMath.Atoms.FencedAtom.CreateBoxCore(TexEnvironment environment) in G:\Projects\xaml-math\src\XamlMath.Shared\Atoms\FencedAtom.cs:line 38
   at XamlMath.Atoms.Atom.CreateBox(TexEnvironment environment) in G:\Projects\xaml-math\src\XamlMath.Shared\Atoms\Atom.cs:line 12
   at XamlMath.TexFormula.CreateBox(TexEnvironment environment) in G:\Projects\xaml-math\src\XamlMath.Shared\TexFormula.cs:line 90
   at WpfMath.Controls.FormulaControl.Render() in G:\Projects\xaml-math\src\WpfMath\Controls\FormulaControl.xaml.cs:line 148
   at WpfMath.Controls.FormulaControl.OnRenderSettingsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) in G:\Projects\xaml-math\src\WpfMath\Controls\FormulaControl.xaml.cs:line 215
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
   at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
   at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
   at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
   at MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)
   at MS.Internal.Data.PropertyPathWorker.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)
   at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
   at System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)
   at WpfMath.Example.MainViewModel.OnPropertyChanged(String propertyName) in G:\Projects\xaml-math\src\WpfMath.Example\MainViewModel.cs:line 170
   at WpfMath.Example.MainViewModel.SetField[T](T& field, T value, String propertyName) in G:\Projects\xaml-math\src\WpfMath.Example\MainViewModel.cs:line 179
   at WpfMath.Example.MainViewModel.set_Formula(String value) in G:\Projects\xaml-math\src\WpfMath.Example\MainViewModel.cs:line 89