icsharpcode / SharpDevelop

#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
2.09k stars 773 forks source link

OverflowException when editing text #404

Closed galich closed 10 years ago

galich commented 10 years ago

I'm not sure how to reproduce it, I was fast typing null in following text sample:

var handler = CanExecuteChanged;

if(handler != n 
                } 

and i've got

Unhandled WPF exception
Exception thrown:
System.OverflowException: Arithmetic operation resulted in an overflow.
   at ICSharpCode.AvalonEdit.Utils.CharRope.ToString(Rope`1 rope, Int32 startIndex, Int32 length) in c:\Dev\src\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\Utils\CharRope.cs:line 59
   at ICSharpCode.AvalonEdit.Document.TextDocument.GetText(Int32 offset, Int32 length) in c:\Dev\src\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\Document\TextDocument.cs:line 165
   at ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngine.GetLineIndent(Int32 lineNr)
   at ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngine.AddDelegateHandlers(CompletionDataWrapper completionList, IType delegateType, Boolean addSemicolon, Boolean addDefault, String optDelegateName)
   at ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngine.AddContextCompletion(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node)
   at ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngine.MagicKeyCompletion(Char completionChar, Boolean controlSpace, Boolean& isComplete)
   at ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngine.GetCompletionData(Int32 offset, Boolean controlSpace)
   at CSharpBinding.Completion.CSharpCompletionBinding.ShowCompletion(ITextEditor editor, Char completionChar, Boolean ctrlSpace)
   at CSharpBinding.Completion.CSharpCompletionBinding.HandleKeyPressed(ITextEditor editor, Char ch)
   at ICSharpCode.SharpDevelop.Editor.CodeCompletion.LazyCodeCompletionBinding.HandleKeyPressed(ITextEditor editor, Char ch) in c:\Dev\src\src\Main\Base\Project\Editor\CodeCompletion\CodeCompletionBinding.cs:line 156
   at ICSharpCode.AvalonEdit.AddIn.CodeEditor.TextAreaTextEntered(Object sender, TextCompositionEventArgs e)
   at ICSharpCode.AvalonEdit.Editing.TextArea.OnTextEntered(TextCompositionEventArgs e) in c:\Dev\src\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\Editing\TextArea.cs:line 831
   at ICSharpCode.AvalonEdit.Editing.TextArea.PerformTextInput(TextCompositionEventArgs e) in c:\Dev\src\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\Editing\TextArea.cs:line 891
   at ICSharpCode.AvalonEdit.Editing.TextArea.OnTextInput(TextCompositionEventArgs e) in c:\Dev\src\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\Editing\TextArea.cs:line 853
   at System.Windows.UIElement.OnTextInputThunk(Object sender, TextCompositionEventArgs e)
   at System.Windows.Input.TextCompositionEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   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.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.TextCompositionManager.UnsafeCompleteComposition(TextComposition composition)
   at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.TextCompositionManager.UnsafeStartComposition(TextComposition composition)
   at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessTextInputAction(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
dgrunwald commented 10 years ago

Looks like there was an off-by-one error causing the crash when typing in a line without indentation. It'll be fixed with the next NRefactory->SharpDevelop merge.