mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-11 23:57:21 -08:00
enhance: block-navigation in text diff view
* It is not necessary to re-calculate all the contents when `UseBlockNavigation` changed * Redraw the text view after `block-navigation` has turned off
This commit is contained in:
parent
9dd4166009
commit
e17b53da42
1 changed files with 16 additions and 8 deletions
|
@ -719,19 +719,22 @@ namespace SourceGit.Views
|
||||||
else if (change.Property == BlockNavigationProperty)
|
else if (change.Property == BlockNavigationProperty)
|
||||||
{
|
{
|
||||||
var oldValue = change.OldValue as ViewModels.BlockNavigation;
|
var oldValue = change.OldValue as ViewModels.BlockNavigation;
|
||||||
var newValue = change.NewValue as ViewModels.BlockNavigation;
|
|
||||||
if (oldValue != null)
|
if (oldValue != null)
|
||||||
|
{
|
||||||
oldValue.PropertyChanged -= OnBlockNavigationPropertyChanged;
|
oldValue.PropertyChanged -= OnBlockNavigationPropertyChanged;
|
||||||
|
if (oldValue.Current != -1)
|
||||||
|
TextArea?.TextView?.Redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
var newValue = change.NewValue as ViewModels.BlockNavigation;
|
||||||
if (newValue != null)
|
if (newValue != null)
|
||||||
newValue.PropertyChanged += OnBlockNavigationPropertyChanged;
|
newValue.PropertyChanged += OnBlockNavigationPropertyChanged;
|
||||||
|
|
||||||
InvalidateVisual();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBlockNavigationPropertyChanged(object _1, PropertyChangedEventArgs _2)
|
private void OnBlockNavigationPropertyChanged(object _1, PropertyChangedEventArgs _2)
|
||||||
{
|
{
|
||||||
TextArea.TextView.Redraw();
|
TextArea?.TextView?.Redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e)
|
private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e)
|
||||||
|
@ -1576,7 +1579,7 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
UseBlockNavigationProperty.Changed.AddClassHandler<TextDiffView>((v, _) =>
|
UseBlockNavigationProperty.Changed.AddClassHandler<TextDiffView>((v, _) =>
|
||||||
{
|
{
|
||||||
v.RefreshContent(v.DataContext as Models.TextDiff, false);
|
v.RefreshBlockNavigation();
|
||||||
});
|
});
|
||||||
|
|
||||||
SelectedChunkProperty.Changed.AddClassHandler<TextDiffView>((v, _) =>
|
SelectedChunkProperty.Changed.AddClassHandler<TextDiffView>((v, _) =>
|
||||||
|
@ -1664,6 +1667,14 @@ namespace SourceGit.Views
|
||||||
Editor.Content = diff;
|
Editor.Content = diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefreshBlockNavigation();
|
||||||
|
|
||||||
|
IsUnstagedChange = diff.Option.IsUnstaged;
|
||||||
|
EnableChunkSelection = diff.Option.WorkingCopyChange != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshBlockNavigation()
|
||||||
|
{
|
||||||
if (UseBlockNavigation)
|
if (UseBlockNavigation)
|
||||||
{
|
{
|
||||||
BlockNavigation = new ViewModels.BlockNavigation(Editor.Content);
|
BlockNavigation = new ViewModels.BlockNavigation(Editor.Content);
|
||||||
|
@ -1674,9 +1685,6 @@ namespace SourceGit.Views
|
||||||
BlockNavigation = null;
|
BlockNavigation = null;
|
||||||
BlockNavigationIndicator = "-/-";
|
BlockNavigationIndicator = "-/-";
|
||||||
}
|
}
|
||||||
|
|
||||||
IsUnstagedChange = diff.Option.IsUnstaged;
|
|
||||||
EnableChunkSelection = diff.Option.WorkingCopyChange != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStageChunk(object _1, RoutedEventArgs _2)
|
private void OnStageChunk(object _1, RoutedEventArgs _2)
|
||||||
|
|
Loading…
Reference in a new issue