Skip to content

Commit

Permalink
Merge pull request #360 from IvaYan/master
Browse files Browse the repository at this point in the history
Fix NRE on losing focus #359
  • Loading branch information
danipen authored Jul 19, 2023
2 parents 02b4ebd + 1a2a644 commit e9cb45e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/AvaloniaEdit/Editing/TextArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,12 @@ public override string SurroundingText

public override TextSelection Selection
{
get => new TextSelection(_textArea.Caret.Position.Column, _textArea.Caret.Position.Column + _textArea.Selection.Length);
get
{
if (_textArea == null)
return new TextSelection(0, 0);
return new TextSelection(_textArea.Caret.Position.Column, _textArea.Caret.Position.Column + _textArea.Selection.Length);
}
set
{
var selection = _textArea.Selection;
Expand Down

0 comments on commit e9cb45e

Please sign in to comment.