AvalonEdit
AvalonEdit copied to clipboard
TextAreaAutomationPeer throws NullReferenceException at some cases
https://github.com/icsharpcode/AvalonEdit/blob/master/ICSharpCode.AvalonEdit/Editing/TextAreaAutomationPeer.cs: line 118
FromElement(editor) may return null in some (random) cases - and the current code throws NullReferenceException. The suggestion (below) is to check returned value and fall-back to 'retrun base.GetPattern(patternInterface)'
public override object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Text)
return this;
if (patternInterface == PatternInterface.Value)
return this;
if (patternInterface == PatternInterface.Scroll) {
TextEditor editor = TextArea.GetService(typeof(TextEditor)) as TextEditor;
if (editor != null)
{
var fromElement = FromElement(editor);
if (fromElement != null)
fromElement.GetPattern(patternInterface);
}
}
return base.GetPattern(patternInterface);
}