mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-15 15:44:59 +00:00
fix: crash when clicking Previous Difference
without visual lines (#1385)
Always scroll to top when the state of `Show All Lines` changed Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
c2187edbe9
commit
06a77502bc
2 changed files with 21 additions and 1 deletions
|
@ -122,7 +122,7 @@
|
|||
|
||||
<ToggleButton Classes="line_path"
|
||||
Width="28"
|
||||
Command="{Binding ToggleFullTextDiff}"
|
||||
Click="OnUseFullTextDiffClicked"
|
||||
IsChecked="{Binding Source={x:Static vm:Preferences.Instance}, Path=UseFullTextDiff, Mode=OneWay}"
|
||||
IsVisible="{Binding IsTextDiff}"
|
||||
ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.All}">
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.VisualTree;
|
||||
|
@ -40,5 +41,24 @@ namespace SourceGit.Views
|
|||
if (sender is TextDiffView textDiff)
|
||||
BlockNavigationIndicator.Text = textDiff.BlockNavigation?.Indicator ?? string.Empty;
|
||||
}
|
||||
|
||||
private void OnUseFullTextDiffClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var textDiffView = this.FindDescendantOfType<TextDiffView>();
|
||||
if (textDiffView == null)
|
||||
return;
|
||||
|
||||
var presenter = textDiffView.FindDescendantOfType<ThemedTextDiffPresenter>();
|
||||
if (presenter == null)
|
||||
return;
|
||||
|
||||
if (presenter.DataContext is Models.TextDiff combined)
|
||||
combined.ScrollOffset = Vector.Zero;
|
||||
else if (presenter.DataContext is ViewModels.TwoSideTextDiff twoSides)
|
||||
twoSides.File = string.Empty; // Just to reset `SyncScrollOffset` without affect UI refresh.
|
||||
|
||||
(DataContext as ViewModels.DiffContext)?.ToggleFullTextDiff();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue