mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
fix: text diff view scrolling issue introduced by AvaloniaEdit 11.2.0
(commit 7caa03a09b
)
- `SyncScrollOffset` does not update in `side-by-side` mode while scrolling - Highlighted chunk is not cleared when scroll by drag scrollbar Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
56253e95c3
commit
8c1e1a3e6a
1 changed files with 9 additions and 24 deletions
|
@ -565,7 +565,6 @@ namespace SourceGit.Views
|
||||||
ScrollToLine(prev.Start);
|
ScrollToLine(prev.Start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NOTE: Not implemented (button hidden) for non-block navigation.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GotoPrevChange()
|
public void GotoPrevChange()
|
||||||
|
@ -678,7 +677,6 @@ namespace SourceGit.Views
|
||||||
ScrollToLine(next.Start);
|
ScrollToLine(next.Start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NOTE: Not implemented (button hidden) for non-block navigation.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
|
@ -1229,7 +1227,7 @@ namespace SourceGit.Views
|
||||||
if (scroller != null)
|
if (scroller != null)
|
||||||
{
|
{
|
||||||
scroller.Bind(ScrollViewer.OffsetProperty, new Binding("ScrollOffset", BindingMode.TwoWay));
|
scroller.Bind(ScrollViewer.OffsetProperty, new Binding("ScrollOffset", BindingMode.TwoWay));
|
||||||
scroller.GotFocus += OnTextViewScrollGotFocus;
|
scroller.ScrollChanged += OnTextViewScrollChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1237,7 +1235,7 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
var scroller = this.FindDescendantOfType<ScrollViewer>();
|
var scroller = this.FindDescendantOfType<ScrollViewer>();
|
||||||
if (scroller != null)
|
if (scroller != null)
|
||||||
scroller.GotFocus -= OnTextViewScrollGotFocus;
|
scroller.ScrollChanged -= OnTextViewScrollChanged;
|
||||||
|
|
||||||
base.OnUnloaded(e);
|
base.OnUnloaded(e);
|
||||||
}
|
}
|
||||||
|
@ -1274,9 +1272,9 @@ namespace SourceGit.Views
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTextViewScrollGotFocus(object sender, GotFocusEventArgs e)
|
private void OnTextViewScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (EnableChunkSelection && !TextArea.IsPointerOver)
|
if (sender is ScrollViewer { IsExpanded: true, IsPointerOver: true } scroller)
|
||||||
TrySetChunk(null);
|
TrySetChunk(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1446,12 +1444,9 @@ namespace SourceGit.Views
|
||||||
_scrollViewer = this.FindDescendantOfType<ScrollViewer>();
|
_scrollViewer = this.FindDescendantOfType<ScrollViewer>();
|
||||||
if (_scrollViewer != null)
|
if (_scrollViewer != null)
|
||||||
{
|
{
|
||||||
_scrollViewer.GotFocus += OnTextViewScrollGotFocus;
|
|
||||||
_scrollViewer.ScrollChanged += OnTextViewScrollChanged;
|
_scrollViewer.ScrollChanged += OnTextViewScrollChanged;
|
||||||
_scrollViewer.Bind(ScrollViewer.OffsetProperty, new Binding("SyncScrollOffset", BindingMode.OneWay));
|
_scrollViewer.Bind(ScrollViewer.OffsetProperty, new Binding("SyncScrollOffset", BindingMode.OneWay));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextArea.PointerWheelChanged += OnTextAreaPointerWheelChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnUnloaded(RoutedEventArgs e)
|
protected override void OnUnloaded(RoutedEventArgs e)
|
||||||
|
@ -1459,12 +1454,9 @@ namespace SourceGit.Views
|
||||||
if (_scrollViewer != null)
|
if (_scrollViewer != null)
|
||||||
{
|
{
|
||||||
_scrollViewer.ScrollChanged -= OnTextViewScrollChanged;
|
_scrollViewer.ScrollChanged -= OnTextViewScrollChanged;
|
||||||
_scrollViewer.GotFocus -= OnTextViewScrollGotFocus;
|
|
||||||
_scrollViewer = null;
|
_scrollViewer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextArea.PointerWheelChanged -= OnTextAreaPointerWheelChanged;
|
|
||||||
|
|
||||||
base.OnUnloaded(e);
|
base.OnUnloaded(e);
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
@ -1499,22 +1491,15 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTextViewScrollGotFocus(object sender, GotFocusEventArgs e)
|
|
||||||
{
|
|
||||||
if (EnableChunkSelection && !TextArea.IsPointerOver)
|
|
||||||
TrySetChunk(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTextViewScrollChanged(object sender, ScrollChangedEventArgs e)
|
private void OnTextViewScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (TextArea.IsFocused && DataContext is ViewModels.TwoSideTextDiff diff)
|
if (IsPointerOver && DataContext is ViewModels.TwoSideTextDiff diff)
|
||||||
|
{
|
||||||
diff.SyncScrollOffset = _scrollViewer?.Offset ?? Vector.Zero;
|
diff.SyncScrollOffset = _scrollViewer?.Offset ?? Vector.Zero;
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTextAreaPointerWheelChanged(object sender, PointerWheelEventArgs e)
|
if (sender is ScrollViewer { IsExpanded: true, IsPointerOver: true } scroller )
|
||||||
{
|
TrySetChunk(null);
|
||||||
if (!TextArea.IsFocused)
|
}
|
||||||
Focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScrollViewer _scrollViewer = null;
|
private ScrollViewer _scrollViewer = null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue