@@ -1334,6 +1334,8 @@ static TextDiffViewMinimap()
13341334
13351335 public override void Render ( DrawingContext context )
13361336 {
1337+ context . DrawRectangle ( Brushes . Transparent , null , new Rect ( 0 , 0 , Bounds . Width , Bounds . Height ) ) ;
1338+
13371339 var total = 0 ;
13381340 if ( DataContext is ViewModels . TwoSideTextDiff twoSideDiff )
13391341 {
@@ -1371,6 +1373,42 @@ protected override void OnDataContextChanged(EventArgs e)
13711373 InvalidateVisual ( ) ;
13721374 }
13731375
1376+ protected override void OnPointerPressed ( PointerPressedEventArgs e )
1377+ {
1378+ base . OnPointerPressed ( e ) ;
1379+
1380+ var range = DisplayRange ;
1381+ if ( range == null || range . End == 0 )
1382+ return ;
1383+
1384+ var total = 0 ;
1385+ if ( DataContext is ViewModels . TwoSideTextDiff twoSideDiff )
1386+ {
1387+ var halfWidth = Bounds . Width * 0.5 ;
1388+ total = Math . Max ( twoSideDiff . Old . Count , twoSideDiff . New . Count ) ;
1389+ }
1390+ else if ( DataContext is ViewModels . CombinedTextDiff combined )
1391+ {
1392+ var data = combined . Data ;
1393+ total = data . Lines . Count ;
1394+ }
1395+ else
1396+ {
1397+ return ;
1398+ }
1399+
1400+ var height = Bounds . Height ;
1401+ var startY = range . Start / ( total * 1.0 ) * height ;
1402+ var endY = range . End / ( total * 1.0 ) * height ;
1403+ var pressedY = e . GetPosition ( this ) . Y ;
1404+ if ( pressedY >= startY && pressedY <= endY )
1405+ return ;
1406+
1407+ var line = Math . Max ( 1 , Math . Min ( total , ( int ) Math . Ceiling ( pressedY * total / height ) ) ) ;
1408+ this . FindAncestorOfType < TextDiffView > ( ) ? . ScrollToLine ( line ) ;
1409+ e . Handled = true ;
1410+ }
1411+
13741412 private void RenderSingleSide ( DrawingContext context , List < Models . TextDiffLine > lines , double x , double width )
13751413 {
13761414 var total = lines . Count ;
@@ -1414,11 +1452,17 @@ public ViewModels.TextDiffSelectedChunk SelectedChunk
14141452 get => GetValue ( SelectedChunkProperty ) ;
14151453 set => SetValue ( SelectedChunkProperty , value ) ;
14161454 }
1455+
14171456 public TextDiffView ( )
14181457 {
14191458 InitializeComponent ( ) ;
14201459 }
14211460
1461+ public void ScrollToLine ( int line )
1462+ {
1463+ this . FindDescendantOfType < ThemedTextDiffPresenter > ( ) ? . ScrollToLine ( line ) ;
1464+ }
1465+
14221466 protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change )
14231467 {
14241468 base . OnPropertyChanged ( change ) ;
0 commit comments