18
18
19
19
using Avalonia ;
20
20
using Avalonia . Input ;
21
+
21
22
using AvaloniaEdit . Document ;
22
23
using AvaloniaEdit . Utils ;
24
+
23
25
using System ;
24
26
using System . ComponentModel ;
25
27
using System . Linq ;
@@ -463,10 +465,6 @@ private void TextArea_MouseLeftButtonDown(object sender, PointerPressedEventArgs
463
465
else
464
466
{
465
467
SimpleSegment startWord ;
466
-
467
- _mode = SelectionMode . WholeWord ;
468
- startWord = GetWordAtMousePosition ( e ) ;
469
-
470
468
if ( e . ClickCount == 3 )
471
469
{
472
470
_mode = SelectionMode . WholeLine ;
@@ -531,7 +529,7 @@ private SimpleSegment GetWordAtMousePosition(PointerEventArgs e)
531
529
pos = pos . WithY ( textView . Bounds . Height ) ;
532
530
pos += textView . ScrollOffset ;
533
531
var line = textView . GetVisualLineFromVisualTop ( pos . Y ) ;
534
- if ( line != null )
532
+ if ( line != null && line . TextLines != null )
535
533
{
536
534
var visualColumn = line . GetVisualColumn ( pos , TextArea . Selection . EnableVirtualSpace ) ;
537
535
var wordStartVc = line . GetNextCaretPosition ( visualColumn + 1 , LogicalDirection . Backward , CaretPositioningMode . WordStartOrSymbol , TextArea . Selection . EnableVirtualSpace ) ;
@@ -562,7 +560,7 @@ private SimpleSegment GetLineAtMousePosition(PointerEventArgs e)
562
560
pos = pos . WithY ( textView . Bounds . Height ) ;
563
561
pos += textView . ScrollOffset ;
564
562
var line = textView . GetVisualLineFromVisualTop ( pos . Y ) ;
565
- return line != null
563
+ return line != null && line . TextLines != null
566
564
? new SimpleSegment ( line . StartOffset , line . LastDocumentLine . EndOffset - line . StartOffset )
567
565
: SimpleSegment . Invalid ;
568
566
}
@@ -585,7 +583,7 @@ private int GetOffsetFromMousePosition(Point positionRelativeToTextView, out int
585
583
if ( pos . Y >= textView . DocumentHeight )
586
584
pos = pos . WithY ( textView . DocumentHeight - ExtensionMethods . Epsilon ) ;
587
585
var line = textView . GetVisualLineFromVisualTop ( pos . Y ) ;
588
- if ( line != null )
586
+ if ( line != null && line . TextLines != null )
589
587
{
590
588
visualColumn = line . GetVisualColumn ( pos , TextArea . Selection . EnableVirtualSpace , out isAtEndOfLine ) ;
591
589
return line . GetRelativeOffset ( visualColumn ) + line . FirstDocumentLine . Offset ;
@@ -607,7 +605,7 @@ private int GetOffsetFromMousePositionFirstTextLineOnly(Point positionRelativeTo
607
605
if ( pos . Y >= textView . DocumentHeight )
608
606
pos = pos . WithY ( textView . DocumentHeight - ExtensionMethods . Epsilon ) ;
609
607
var line = textView . GetVisualLineFromVisualTop ( pos . Y ) ;
610
- if ( line != null )
608
+ if ( line != null && line . TextLines != null )
611
609
{
612
610
visualColumn = line . GetVisualColumn ( line . TextLines . First ( ) , pos . X , TextArea . Selection . EnableVirtualSpace ) ;
613
611
return line . GetRelativeOffset ( visualColumn ) + line . FirstDocumentLine . Offset ;
0 commit comments