diff --git a/src/ViewModels/TwoSideTextDiff.cs b/src/ViewModels/TwoSideTextDiff.cs
index d5668449..3fb1e63b 100644
--- a/src/ViewModels/TwoSideTextDiff.cs
+++ b/src/ViewModels/TwoSideTextDiff.cs
@@ -20,17 +20,10 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _syncScrollOffset, value);
}
- public Models.DiffOption Option
- {
- get;
- set;
- }
-
public TwoSideTextDiff(Models.TextDiff diff, TwoSideTextDiff previous = null)
{
File = diff.File;
MaxLineNumber = diff.MaxLineNumber;
- Option = diff.Option;
foreach (var line in diff.Lines)
{
diff --git a/src/Views/TextDiffView.axaml b/src/Views/TextDiffView.axaml
index 72a952d3..4b1cad3d 100644
--- a/src/Views/TextDiffView.axaml
+++ b/src/Views/TextDiffView.axaml
@@ -26,6 +26,7 @@
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
+ EnableChunkSelection="{Binding #ThisControl.EnableChunkSelection}"
SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/>
@@ -46,6 +47,7 @@
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
+ EnableChunkSelection="{Binding #ThisControl.EnableChunkSelection}"
SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/>
@@ -65,6 +67,7 @@
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
+ EnableChunkSelection="{Binding #ThisControl.EnableChunkSelection}"
SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/>
diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs
index d0a54782..d8972c80 100644
--- a/src/Views/TextDiffView.axaml.cs
+++ b/src/Views/TextDiffView.axaml.cs
@@ -336,6 +336,15 @@ namespace SourceGit.Views
set => SetValue(ShowHiddenSymbolsProperty, value);
}
+ public static readonly StyledProperty EnableChunkSelectionProperty =
+ AvaloniaProperty.Register(nameof(EnableChunkSelection));
+
+ public bool EnableChunkSelection
+ {
+ get => GetValue(EnableChunkSelectionProperty);
+ set => SetValue(EnableChunkSelectionProperty, value);
+ }
+
public static readonly StyledProperty SelectedChunkProperty =
AvaloniaProperty.Register(nameof(SelectedChunk));
@@ -479,13 +488,13 @@ namespace SourceGit.Views
private void OnTextViewPointerMoved(object sender, PointerEventArgs e)
{
- if (sender is TextView view)
+ if (EnableChunkSelection && sender is TextView view)
UpdateSelectedChunk(e.GetPosition(view).Y + view.VerticalOffset);
}
private void OnTextViewPointerWheelChanged(object sender, PointerWheelEventArgs e)
{
- if (sender is TextView view)
+ if (EnableChunkSelection && sender is TextView view)
{
var y = e.GetPosition(view).Y + view.VerticalOffset;
Dispatcher.UIThread.Post(() => UpdateSelectedChunk(y));
@@ -636,7 +645,7 @@ namespace SourceGit.Views
public override void UpdateSelectedChunk(double y)
{
var diff = DataContext as Models.TextDiff;
- if (diff == null || diff.Option.WorkingCopyChange == null)
+ if (diff == null)
return;
var view = TextArea.TextView;
@@ -796,7 +805,7 @@ namespace SourceGit.Views
public override void UpdateSelectedChunk(double y)
{
var diff = DataContext as ViewModels.TwoSideTextDiff;
- if (diff == null || diff.Option.WorkingCopyChange == null)
+ if (diff == null)
return;
var parent = this.FindAncestorOfType();
@@ -1012,6 +1021,15 @@ namespace SourceGit.Views
set => SetValue(IsUnstagedChangeProperty, value);
}
+ public static readonly StyledProperty EnableChunkSelectionProperty =
+ AvaloniaProperty.Register(nameof(EnableChunkSelection));
+
+ public bool EnableChunkSelection
+ {
+ get => GetValue(EnableChunkSelectionProperty);
+ set => SetValue(EnableChunkSelectionProperty, value);
+ }
+
static TextDiffView()
{
UseSideBySideDiffProperty.Changed.AddClassHandler((v, _) =>
@@ -1069,6 +1087,7 @@ namespace SourceGit.Views
Editor.Content = diff;
IsUnstagedChange = diff.Option.IsUnstaged;
+ EnableChunkSelection = diff.Option.WorkingCopyChange != null;
}
protected override void OnPointerExited(PointerEventArgs e)
@@ -1160,8 +1179,6 @@ namespace SourceGit.Views
if (!selection.HasChanges)
return;
- // If all changes has been selected the use method provided by ViewModels.WorkingCopy.
- // Otherwise, use `git apply`
if (!selection.HasLeftChanges)
{
var workcopyView = this.FindAncestorOfType();
@@ -1218,8 +1235,6 @@ namespace SourceGit.Views
if (!selection.HasChanges)
return;
- // If all changes has been selected the use method provided by ViewModels.WorkingCopy.
- // Otherwise, use `git apply`
if (!selection.HasLeftChanges)
{
var workcopyView = this.FindAncestorOfType();