Knagis/CommonMark.NET

Fault when parsing empty string

Closed this issue · 2 comments

This is new. When I parse an empty string with Source Tracking enabled I get the following exception and stack trace:

CommonMark.CommonMarkException was unhandled
  HResult=-2146233088
  Message=An error occurred while finalizing open containers.
  Source=CommonMark
  StackTrace:
       at CommonMark.CommonMarkConverter.ProcessStage1(TextReader source, CommonMarkSettings settings) in C:\Users\knagis\SkyDrive\Programming\CommonMark\CommonMark\CommonMarkConverter.cs:line 151
       at MarkdownEdit.Models.MarkdownHighlightingColorizer.ParseDocument(String text) in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\Models\MarkdownHighlightingColorizer.cs:line 187
       at MarkdownEdit.Models.MarkdownHighlightingColorizer.OnTextChanged(String text) in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\Models\MarkdownHighlightingColorizer.cs:line 173
       at MarkdownEdit.Controls.Editor.<>c__DisplayClass13.<SetupSyntaxHighlighting>b__14(Object s, EventArgs e) in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\Controls\Editor.xaml.cs:line 107
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at MarkdownEdit.Controls.Editor.EditBoxOnTextChanged(Object sender, EventArgs eventArgs) in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\Controls\Editor.xaml.cs:line 480
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at ICSharpCode.AvalonEdit.TextEditor.OnTextChanged(EventArgs e)
       at ICSharpCode.AvalonEdit.TextEditor.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
       at ICSharpCode.AvalonEdit.TextEditor.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
       at System.Windows.WeakEventManager.ListenerList.DeliverEvent(Listener& listener, Object sender, EventArgs args, Type managerType)
       at System.Windows.WeakEventManager.ListenerList.DeliverEvent(Object sender, EventArgs args, Type managerType)
       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
       at ICSharpCode.AvalonEdit.Document.TextDocument.FireChangeEvents()
       at ICSharpCode.AvalonEdit.Document.TextDocument.EndUpdate()
       at ICSharpCode.AvalonEdit.Document.TextDocument.Replace(Int32 offset, Int32 length, ITextSource text, OffsetChangeMap offsetChangeMap)
       at ICSharpCode.AvalonEdit.Document.TextDocument.Replace(Int32 offset, Int32 length, String text)
       at ICSharpCode.AvalonEdit.Document.TextDocument.set_Text(String value)
       at ICSharpCode.AvalonEdit.TextEditor.set_Text(String value)
       at MarkdownEdit.Controls.Editor.set_Text(String value) in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\Controls\Editor.xaml.cs:line 500
       at MarkdownEdit.Controls.Editor.<NewFile>b__21() in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\Controls\Editor.xaml.cs:line 235
       at MarkdownEdit.Controls.Editor.Execute(Action action) in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\Controls\Editor.xaml.cs:line 222
       at MarkdownEdit.Controls.Editor.NewFile() in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\Controls\Editor.xaml.cs:line 232
       at MarkdownEdit.Controls.MainWindow.ExecuteNewFile(Object sender, ExecutedRoutedEventArgs ea) in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\Controls\MainWindow.xaml.cs:line 128
       at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
       at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
       at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)
       at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
       at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
       at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
       at System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
       at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at MarkdownEdit.App.Main() in C:\Users\Mike\Documents\GitHub\MarkdownEdit\src\MarkdownEdit\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       HResult=-2147467261
       Message=Object reference not set to an instance of an object.
       Source=CommonMark
       StackTrace:
            at CommonMark.Parser.BlockMethods.Finalize(Block b, LineInfo line) in C:\Users\knagis\SkyDrive\Programming\CommonMark\CommonMark\Parser\BlockMethods.cs:line 110
            at CommonMark.CommonMarkConverter.ProcessStage1(TextReader source, CommonMarkSettings settings) in C:\Users\knagis\SkyDrive\Programming\CommonMark\CommonMark\CommonMarkConverter.cs:line 141
       InnerException: 

Version 0.8.3 released.

I can confirm this fixes the issue. Thanks!