Skip to content

Commit

Permalink
Merge pull request #6429 from wieslawsoltes/AutoCompleteBoxNullRefere…
Browse files Browse the repository at this point in the history
…nceFix

Check if TextBox.Text is null in AutoCompleteBox
  • Loading branch information
maxkatz6 committed Aug 16, 2021
2 parents 2234d55 + 08dea64 commit 8faa490
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Avalonia.Controls/AutoCompleteBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,7 @@ private void TextUpdated(string newText, bool userInitiated)
// The TextBox.TextChanged event was not firing immediately and
// was causing an immediate update, even with wrapping. If there is
// a selection currently, no update should happen.
if (IsTextCompletionEnabled && TextBox != null && TextBoxSelectionLength > 0 && TextBoxSelectionStart != TextBox.Text.Length)
if (IsTextCompletionEnabled && TextBox != null && TextBoxSelectionLength > 0 && TextBoxSelectionStart != (TextBox.Text?.Length ?? 0))
{
return;
}
Expand Down Expand Up @@ -2303,7 +2303,7 @@ private void UpdateTextCompletion(bool userInitiated)
{
if (IsTextCompletionEnabled && TextBox != null && userInitiated)
{
int currentLength = TextBox.Text.Length;
int currentLength = TextBox.Text?.Length ?? 0;
int selectionStart = TextBoxSelectionStart;
if (selectionStart == text.Length && selectionStart > _textSelectionStart)
{
Expand Down

0 comments on commit 8faa490

Please sign in to comment.