From 934d784d4081b1bd466c3813e26f4c9b3c98a8c6 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 17 Sep 2024 22:26:35 +0800 Subject: [PATCH] fix: unable to access the `Stage/Unstage` buttons in diff viewer when line wrap is enabled (#481) * disable line wrap in side-by-side diff mode --- src/Views/TextDiffView.axaml | 4 ++-- src/Views/TextDiffView.axaml.cs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Views/TextDiffView.axaml b/src/Views/TextDiffView.axaml index 1ab75ef6..b14bb07d 100644 --- a/src/Views/TextDiffView.axaml +++ b/src/Views/TextDiffView.axaml @@ -45,7 +45,7 @@ IndicatorForeground="{DynamicResource Brush.FG2}" FontFamily="{DynamicResource Fonts.Monospace}" UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}" - WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}" + WordWrap="False" ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}" EnableChunkSelection="{Binding #ThisControl.EnableChunkSelection}" SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/> @@ -65,7 +65,7 @@ IndicatorForeground="{DynamicResource Brush.FG2}" FontFamily="{DynamicResource Fonts.Monospace}" UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}" - WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}" + WordWrap="False" 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 b2459127..02564428 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -519,7 +519,17 @@ namespace SourceGit.Views private void OnTextViewPointerMoved(object sender, PointerEventArgs e) { if (EnableChunkSelection && sender is TextView view) + { + var chunk = SelectedChunk; + if (chunk != null) + { + var rect = new Rect(0, chunk.Y, Bounds.Width, chunk.Height); + if (rect.Contains(e.GetPosition(this))) + return; + } + UpdateSelectedChunk(e.GetPosition(view).Y + view.VerticalOffset); + } } private void OnTextViewPointerWheelChanged(object sender, PointerWheelEventArgs e)