@@ -437,8 +437,8 @@ protected override void OnLoaded(RoutedEventArgs e)
437
437
base . OnLoaded ( e ) ;
438
438
439
439
TextArea . TextView . ContextRequested += OnTextViewContextRequested ;
440
- TextArea . TextView . PointerEntered += OnTextViewPointerEntered ;
441
- TextArea . TextView . PointerMoved += OnTextViewPointerMoved ;
440
+ TextArea . TextView . PointerEntered += OnTextViewPointerChanged ;
441
+ TextArea . TextView . PointerMoved += OnTextViewPointerChanged ;
442
442
TextArea . TextView . PointerWheelChanged += OnTextViewPointerWheelChanged ;
443
443
444
444
UpdateTextMate ( ) ;
@@ -449,8 +449,8 @@ protected override void OnUnloaded(RoutedEventArgs e)
449
449
base . OnUnloaded ( e ) ;
450
450
451
451
TextArea . TextView . ContextRequested -= OnTextViewContextRequested ;
452
- TextArea . TextView . PointerEntered -= OnTextViewPointerEntered ;
453
- TextArea . TextView . PointerMoved -= OnTextViewPointerMoved ;
452
+ TextArea . TextView . PointerEntered -= OnTextViewPointerChanged ;
453
+ TextArea . TextView . PointerMoved -= OnTextViewPointerChanged ;
454
454
TextArea . TextView . PointerWheelChanged -= OnTextViewPointerWheelChanged ;
455
455
456
456
if ( _textMate != null )
@@ -510,35 +510,43 @@ private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs
510
510
e . Handled = true ;
511
511
}
512
512
513
- private void OnTextViewPointerEntered ( object sender , PointerEventArgs e )
513
+ private void OnTextViewPointerChanged ( object sender , PointerEventArgs e )
514
514
{
515
515
if ( EnableChunkSelection && sender is TextView view )
516
516
{
517
- var chunk = SelectedChunk ;
518
- if ( chunk != null )
517
+ var selection = TextArea . Selection ;
518
+ if ( selection == null || selection . IsEmpty )
519
519
{
520
- var rect = new Rect ( 0 , chunk . Y , Bounds . Width , chunk . Height ) ;
521
- if ( rect . Contains ( e . GetPosition ( this ) ) )
522
- return ;
523
- }
520
+ if ( _lastSelectStart != _lastSelectEnd )
521
+ {
522
+ _lastSelectStart = TextLocation . Empty ;
523
+ _lastSelectEnd = TextLocation . Empty ;
524
+ }
524
525
525
- UpdateSelectedChunk ( e . GetPosition ( view ) . Y + view . VerticalOffset ) ;
526
- }
527
- }
526
+ var chunk = SelectedChunk ;
527
+ if ( chunk != null )
528
+ {
529
+ var rect = new Rect ( 0 , chunk . Y , Bounds . Width , chunk . Height ) ;
530
+ if ( rect . Contains ( e . GetPosition ( this ) ) )
531
+ return ;
532
+ }
528
533
529
- private void OnTextViewPointerMoved ( object sender , PointerEventArgs e )
530
- {
531
- if ( EnableChunkSelection && sender is TextView view )
532
- {
533
- var chunk = SelectedChunk ;
534
- if ( chunk != null )
534
+ UpdateSelectedChunk ( e . GetPosition ( view ) . Y + view . VerticalOffset ) ;
535
+ return ;
536
+ }
537
+
538
+ var start = selection . StartPosition . Location ;
539
+ var end = selection . EndPosition . Location ;
540
+ if ( _lastSelectStart != start || _lastSelectEnd != end )
535
541
{
536
- var rect = new Rect ( 0 , chunk . Y , Bounds . Width , chunk . Height ) ;
537
- if ( rect . Contains ( e . GetPosition ( this ) ) )
538
- return ;
542
+ _lastSelectStart = start ;
543
+ _lastSelectEnd = end ;
544
+ UpdateSelectedChunk ( e . GetPosition ( view ) . Y + view . VerticalOffset ) ;
545
+ return ;
539
546
}
540
547
541
- UpdateSelectedChunk ( e . GetPosition ( view ) . Y + view . VerticalOffset ) ;
548
+ if ( SelectedChunk == null )
549
+ UpdateSelectedChunk ( e . GetPosition ( view ) . Y + view . VerticalOffset ) ;
542
550
}
543
551
}
544
552
@@ -657,7 +665,9 @@ private void UpdateTextMate()
657
665
}
658
666
659
667
private TextMate . Installation _textMate = null ;
660
- protected LineStyleTransformer _lineStyleTransformer = null ;
668
+ private TextLocation _lastSelectStart = TextLocation . Empty ;
669
+ private TextLocation _lastSelectEnd = TextLocation . Empty ;
670
+ private LineStyleTransformer _lineStyleTransformer = null ;
661
671
}
662
672
663
673
public class CombinedTextDiffPresenter : ThemedTextDiffPresenter
0 commit comments