enhance: only raise BlockNavigationChangedEvent when UseBlockNavigation enabled

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-03-21 18:00:46 +08:00
parent 9590f96a44
commit d335cac167
No known key found for this signature in database
2 changed files with 12 additions and 6 deletions

View file

@ -37,7 +37,7 @@ namespace SourceGit.Views
private void OnBlockNavigationChanged(object sender, RoutedEventArgs e) private void OnBlockNavigationChanged(object sender, RoutedEventArgs e)
{ {
if (sender is TextDiffView { UseBlockNavigation: true } textDiff) if (sender is TextDiffView textDiff)
BlockNavigationIndicator.Text = textDiff.BlockNavigation?.Indicator ?? string.Empty; BlockNavigationIndicator.Text = textDiff.BlockNavigation?.Indicator ?? string.Empty;
} }
} }

View file

@ -1746,25 +1746,25 @@ namespace SourceGit.Views
public void GotoFirstChange() public void GotoFirstChange()
{ {
this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoFirstChange(); this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoFirstChange();
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent)); TryRaiseBlockNavigationChanged();
} }
public void GotoPrevChange() public void GotoPrevChange()
{ {
this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoPrevChange(); this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoPrevChange();
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent)); TryRaiseBlockNavigationChanged();
} }
public void GotoNextChange() public void GotoNextChange()
{ {
this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoNextChange(); this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoNextChange();
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent)); TryRaiseBlockNavigationChanged();
} }
public void GotoLastChange() public void GotoLastChange()
{ {
this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoLastChange(); this.FindDescendantOfType<ThemedTextDiffPresenter>()?.GotoLastChange();
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent)); TryRaiseBlockNavigationChanged();
} }
protected override void OnDataContextChanged(EventArgs e) protected override void OnDataContextChanged(EventArgs e)
@ -1818,7 +1818,7 @@ namespace SourceGit.Views
else else
BlockNavigation = null; BlockNavigation = null;
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent)); TryRaiseBlockNavigationChanged();
} }
private void OnStageChunk(object _1, RoutedEventArgs _2) private void OnStageChunk(object _1, RoutedEventArgs _2)
@ -1990,5 +1990,11 @@ namespace SourceGit.Views
repo.MarkWorkingCopyDirtyManually(); repo.MarkWorkingCopyDirtyManually();
repo.SetWatcherEnabled(true); repo.SetWatcherEnabled(true);
} }
private void TryRaiseBlockNavigationChanged()
{
if (UseBlockNavigation)
RaiseEvent(new RoutedEventArgs(BlockNavigationChangedEvent));
}
} }
} }