Skip to content

Commit ee657f5

Browse files
committed
enhance: use Parent instead of find TextDiffView first before find first ThemedTextDiffPresenter
Signed-off-by: leo <[email protected]>
1 parent bb52b0d commit ee657f5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Views/TextDiffView.axaml.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Avalonia.Data;
1212
using Avalonia.Input;
1313
using Avalonia.Interactivity;
14+
using Avalonia.LogicalTree;
1415
using Avalonia.Media;
1516
using Avalonia.Threading;
1617
using Avalonia.VisualTree;
@@ -1405,7 +1406,9 @@ protected override void OnPointerPressed(PointerPressedEventArgs e)
14051406
return;
14061407

14071408
var line = Math.Max(1, Math.Min(total, (int)Math.Ceiling(pressedY * total / height)));
1408-
this.FindAncestorOfType<TextDiffView>()?.ScrollToLine(line);
1409+
if (this.Parent is Control parent)
1410+
parent.FindLogicalDescendantOfType<ThemedTextDiffPresenter>()?.ScrollToLine(line);
1411+
14091412
e.Handled = true;
14101413
}
14111414

@@ -1458,11 +1461,6 @@ public TextDiffView()
14581461
InitializeComponent();
14591462
}
14601463

1461-
public void ScrollToLine(int line)
1462-
{
1463-
this.FindDescendantOfType<ThemedTextDiffPresenter>()?.ScrollToLine(line);
1464-
}
1465-
14661464
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
14671465
{
14681466
base.OnPropertyChanged(change);

0 commit comments

Comments
 (0)