Skip to content

Commit e9cb45e

Browse files
authored
Merge pull request #360 from IvaYan/master
Fix NRE on losing focus #359
2 parents 02b4ebd + 1a2a644 commit e9cb45e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/AvaloniaEdit/Editing/TextArea.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,12 @@ public override string SurroundingText
11921192

11931193
public override TextSelection Selection
11941194
{
1195-
get => new TextSelection(_textArea.Caret.Position.Column, _textArea.Caret.Position.Column + _textArea.Selection.Length);
1195+
get
1196+
{
1197+
if (_textArea == null)
1198+
return new TextSelection(0, 0);
1199+
return new TextSelection(_textArea.Caret.Position.Column, _textArea.Caret.Position.Column + _textArea.Selection.Length);
1200+
}
11961201
set
11971202
{
11981203
var selection = _textArea.Selection;

0 commit comments

Comments
 (0)