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

CompletionWindow crash NullReferenceException #308

Open
PerfectlyFineCode opened this issue Feb 14, 2023 · 1 comment
Open

CompletionWindow crash NullReferenceException #308

PerfectlyFineCode opened this issue Feb 14, 2023 · 1 comment

Comments

@PerfectlyFineCode
Copy link

PerfectlyFineCode commented Feb 14, 2023

AvaloniaEdit version: 0.10.12.2
Avalonia version: 0.10.18
Runtime version: .NET 7.0

Crashes with exceptions

Null Reference Exception

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at AvaloniaEdit.CodeCompletion.CompletionList.SelectItemFiltering(String query)
   at AvaloniaEdit.CodeCompletion.CompletionList.SelectItem(String text)
   at AvaloniaEdit.CodeCompletion.CompletionWindow.CaretPositionChanged(Object sender, EventArgs e)
   at AvaloniaEdit.Editing.Caret.OnDocumentUpdateFinished()
   at AvaloniaEdit.Editing.TextArea.OnUpdateFinished(Object sender, EventArgs e)
   at InvokeStub_EventHandler.Invoke(Object, Object, IntPtr*)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(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.EndUpdate()
   at AvaloniaEdit.Document.TextDocument.Replace(Int32 offset, Int32 length, ITextSource text, OffsetChangeMap offsetChangeMap)
   at AvaloniaEdit.Document.TextDocument.Insert(Int32 offset, String text)
   at AvaloniaEdit.Editing.EmptySelection.ReplaceSelectionWithText(String newText)
   at AvaloniaEdit.Editing.TextArea.ReplaceSelectionWithText(String newText)
   at AvaloniaEdit.Editing.TextArea.PerformTextInput(TextInputEventArgs e)
   at AvaloniaEdit.Editing.TextArea.OnTextInput(TextInputEventArgs e)
   at Avalonia.Input.InputElement.<>c.<.cctor>b__32_4(InputElement x, TextInputEventArgs e) in /_/src/Avalonia.Input/InputElement.cs:line 218
   at Avalonia.Interactivity.RoutedEvent`1.<>c__DisplayClass2_0`1.<AddClassHandler>g__Adapter|0(Object sender, RoutedEventArgs e) in /_/src/Avalonia.Interactivity/RoutedEvent.cs:line 143
   at Avalonia.Interactivity.RoutedEvent.<>c__DisplayClass23_0.<AddClassHandler>b__0(ValueTuple`2 args) in /_/src/Avalonia.Interactivity/RoutedEvent.cs:line 92
   at System.Reactive.AnonymousObserver`1.OnNextCore(T value) in /_/Rx.NET/Source/src/System.Reactive/AnonymousObserver.cs:line 67
   at System.Reactive.ObserverBase`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/ObserverBase.cs:line 34
   at System.Reactive.Subjects.Subject`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 147
   at Avalonia.Interactivity.RoutedEvent.InvokeRaised(Object sender, RoutedEventArgs e) in /_/src/Avalonia.Interactivity/RoutedEvent.cs:line 99
   at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e) in /_/src/Avalonia.Interactivity/EventRoute.cs:line 148
   at Avalonia.Interactivity.EventRoute.RaiseEvent(IInteractive source, RoutedEventArgs e) in /_/src/Avalonia.Interactivity/EventRoute.cs:line 101
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in /_/src/Avalonia.Interactivity/Interactive.cs:line 122
   at Avalonia.Input.KeyboardDevice.ProcessRawEvent(RawInputEventArgs e) in /_/src/Avalonia.Input/KeyboardDevice.cs:line 264
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e) in /_/src/Avalonia.Input/InputManager.cs:line 35
   at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e) in /_/src/Avalonia.Controls/TopLevel.cs:line 508
   at Avalonia.Win32.WindowImpl.AppWndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in /_/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs:line 520
   at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in /_/src/Windows/Avalonia.Win32/WindowImpl.WndProc.cs:line 30
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) in /_/src/Windows/Avalonia.Win32/Win32Platform.cs:line 210
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in /_/src/Avalonia.Base/Threading/Dispatcher.cs:line 65
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 120
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 209
   at AvaloniaTest.Program.Main(String[] args) in D:\Coding\Softwares\Avalonia\AvaloniaTest\Avaloniatest\Program.cs:line 13

I am using this example
http://avalonedit.net/documentation/html/47c58b63-f30c-4290-a2f2-881d21227446.htm

With TextMateSharp.Grammars and Avalonia.TextMate

it seems to crash upon creating a new instance of CompletionWindow
example:

CompletionWindow _completionWindow = new CompletionWindow(_textEditor.TextArea);

I've done debugging and I've double-checked that _textEditor.TextArea does not return null, and it does not return null

@PerfectlyFineCode PerfectlyFineCode changed the title CompletionWindow crash NullRefException / TargetInvocationException CompletionWindow crash NullReferenceException Feb 14, 2023
@jhimes144
Copy link

jhimes144 commented Jun 22, 2023

I'm also experiencing this issue.

The problem is caused by lines 243 - 244 of CompletionList.cs. ApplyTemplate() does not result in OnApplyTemplate getting called every time. Seems like an upstream issue.

if (_listBox == null) ApplyTemplate();

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

2 participants