mhutch / MonoDevelop.AddinMaker

Extension to make it easier to create Visual Studio for Mac / MonoDevelop extensions
MIT License
50 stars 26 forks source link

Fatal error on Mono.TextEditor.CaretImpl.PositionChanged_ITextCaret #69

Closed nosami closed 5 years ago

nosami commented 5 years ago

First reported here and later here

I noticed the following error in the logs but I can't reproduce.

FATAL ERROR [2018-09-22 20:37:54Z]: An unhandled exception has occurred. Terminating Visual Studio? True
System.ArgumentNullException: Value cannot be null.
Parameter name: targetSnapshot
  at Microsoft.VisualStudio.Text.SnapshotPoint.TranslateTo (Microsoft.VisualStudio.Text.ITextSnapshot targetSnapshot, Microsoft.VisualStudio.Text.PointTrackingMode trackingMode) [0x00013] in <08755f5947d542f1a0375d88d9301ac1>:0 
  at MonoDevelop.AddinMaker.Pads.RoslynSyntaxVisualizer.SelectBestMatchForCaret () [0x0003d] in <81cc69758bd24d4d8da7ff06ef72fe28>:0 
  at MonoDevelop.AddinMaker.Pads.RoslynSyntaxVisualizer.CaretPositionChanged (System.Object sender, Microsoft.VisualStudio.Text.Editor.CaretPositionChangedEventArgs e) [0x00000] in <81cc69758bd24d4d8da7ff06ef72fe28>:0 
  at (wrapper delegate-invoke) System.EventHandler`1[Microsoft.VisualStudio.Text.Editor.CaretPositionChangedEventArgs].invoke_void_object_TEventArgs(object,Microsoft.VisualStudio.Text.Editor.CaretPositionChangedEventArgs)
  at Mono.TextEditor.CaretImpl.PositionChanged_ITextCaret (MonoDevelop.Ide.Editor.CaretLocationEventArgs args) [0x000b3] in /Users/vsts/agent/2.140.0/work/1/s/monodevelop/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/CaretImpl.ITextCaret.cs:125

It seems like we can just add a null reference check.