Skip to content

Commit d335cac

Browse files
committed
enhance: only raise BlockNavigationChangedEvent when UseBlockNavigation enabled
Signed-off-by: leo <[email protected]>
1 parent 9590f96 commit d335cac

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Views/DiffView.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private void OnGotoLastChange(object _, RoutedEventArgs e)
3737

3838
private void OnBlockNavigationChanged(object sender, RoutedEventArgs e)
3939
{
40-
if (sender is TextDiffView { UseBlockNavigation: true } textDiff)
40+
if (sender is TextDiffView textDiff)
4141
BlockNavigationIndicator.Text = textDiff.BlockNavigation?.Indicator ?? string.Empty;
4242
}
4343
}

src/Views/TextDiffView.axaml.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,25 +1746,25 @@ public TextDiffView()
17461746
public void GotoFirstChange()
17471747
{
17481748
this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoFirstChange();
1749-
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent));
1749+
TryRaiseBlockNavigationChanged();
17501750
}
17511751

17521752
public void GotoPrevChange()
17531753
{
17541754
this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoPrevChange();
1755-
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent));
1755+
TryRaiseBlockNavigationChanged();
17561756
}
17571757

17581758
public void GotoNextChange()
17591759
{
17601760
this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoNextChange();
1761-
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent));
1761+
TryRaiseBlockNavigationChanged();
17621762
}
17631763

17641764
public void GotoLastChange()
17651765
{
17661766
this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoLastChange();
1767-
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent));
1767+
TryRaiseBlockNavigationChanged();
17681768
}
17691769

17701770
protected override void OnDataContextChanged(EventArgs e)
@@ -1818,7 +1818,7 @@ private void RefreshBlockNavigation()
18181818
else
18191819
BlockNavigation = null;
18201820

1821-
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent));
1821+
TryRaiseBlockNavigationChanged();
18221822
}
18231823

18241824
private void OnStageChunk(object _1, RoutedEventArgs _2)
@@ -1990,5 +1990,11 @@ private void OnDiscardChunk(object _1, RoutedEventArgs _2)
19901990
repo.MarkWorkingCopyDirtyManually();
19911991
repo.SetWatcherEnabled(true);
19921992
}
1993+
1994+
private void TryRaiseBlockNavigationChanged()
1995+
{
1996+
if (UseBlockNavigation)
1997+
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent));
1998+
}
19931999
}
19942000
}

0 commit comments

Comments
 (0)