Skip to content
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

Exception updating TextDocument.Text with Foldings #480

Open
IvanJosipovic opened this issue Jan 30, 2025 · 0 comments
Open

Exception updating TextDocument.Text with Foldings #480

IvanJosipovic opened this issue Jan 30, 2025 · 0 comments

Comments

@IvanJosipovic
Copy link

I am experiencing an occasional exception when updating TextDocument.Text attached to a TextEditor with Foldings.

Version: Avalonia.AvaloniaEdit 11.1.0

Repro Steps:

  1. Create TextEditor with FoldingManager
  2. Set TextDocument.Text
  3. Update Foldings
  4. Update TextDocument.Text
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.InvalidOperationException: Document is null
   at AvaloniaEdit.Rendering.TextView.CollapseLines(DocumentLine start, DocumentLine end)
   at AvaloniaEdit.Folding.FoldingSection.ValidateCollapsedLineSections()
   at AvaloniaEdit.Folding.FoldingSection.OnSegmentChanged()
   at AvaloniaEdit.Document.TextSegmentCollection`1.ReplaceText(OffsetChangeMapEntry change)
   at AvaloniaEdit.Document.TextSegmentCollection`1.OnDocumentChanged(Object sender, DocumentChangeEventArgs e)
   at AvaloniaEdit.Folding.FoldingManager.OnDocumentChanged(Object sender, DocumentChangeEventArgs e)
   at InvokeStub_EventHandler`1.Invoke(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at AvaloniaEdit.Utils.WeakEventManagerBase`4.WeakHandlerList.DeliverEvent(Object sender, TEventArgs args)
   at AvaloniaEdit.Utils.WeakEventManagerBase`4.PrivateDeliverEvent(Object sender, TEventArgs args)
   at AvaloniaEdit.Document.TextDocument.DoReplace(Int32 offset, Int32 length, ITextSource newText, OffsetChangeMap offsetChangeMap)
   at AvaloniaEdit.Document.TextDocument.Replace(Int32 offset, Int32 length, ITextSource text, OffsetChangeMap offsetChangeMap)
   at AvaloniaEdit.Document.TextDocument.set_Text(String value)
...
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.InvalidOperationException: Document is null
   at AvaloniaEdit.Rendering.TextView.CollapseLines(DocumentLine start, DocumentLine end)
   at AvaloniaEdit.Folding.FoldingSection.ValidateCollapsedLineSections()
   at AvaloniaEdit.Folding.FoldingSection.OnSegmentChanged()
   at AvaloniaEdit.Document.TextSegmentCollection`1.ReplaceText(OffsetChangeMapEntry change)
   at AvaloniaEdit.Document.TextSegmentCollection`1.UpdateOffsetsInternal(OffsetChangeMapEntry change)
   at AvaloniaEdit.Document.TextSegmentCollection`1.OnDocumentChanged(Object sender, DocumentChangeEventArgs e)
   at AvaloniaEdit.Document.TextSegmentCollection`1.UpdateOffsets(DocumentChangeEventArgs e)
   at AvaloniaEdit.Folding.FoldingManager.OnDocumentChanged(Object sender, DocumentChangeEventArgs e)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at AvaloniaEdit.Utils.WeakEventManagerBase`4.WeakHandlerList.DeliverEvent(Object sender, TEventArgs args)
   at AvaloniaEdit.Utils.WeakEventManagerBase`4.PrivateDeliverEvent(Object sender, TEventArgs args)
   at AvaloniaEdit.Utils.WeakEventManagerBase`4.DeliverEvent(Object sender, TEventArgs args)
   at AvaloniaEdit.Document.TextDocument.DoReplace(Int32 offset, Int32 length, ITextSource newText, OffsetChangeMap offsetChangeMap)
   at AvaloniaEdit.Document.TextDocument.Replace(Int32 offset, Int32 length, ITextSource text, OffsetChangeMap offsetChangeMap)
   at AvaloniaEdit.Document.TextDocument.Replace(Int32 offset, Int32 length, String text)
   at AvaloniaEdit.Document.TextDocument.set_Text(String value)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant