Skip to content

Commit 190b4d9

Browse files
authored
fix: let the diff view wake up before its first curtain call (#2496)
Double-tapping a change in the Info tab raced against the tab switch: the view poked the TabControl directly while SelectedChanges was still clearing DiffContext to null, so the right-hand AvaloniaEdit rendered blank until a later file switch rebuilt it. Drive the switch through the ViewModel instead -- set SelectedChanges first, then ActiveTabIndex, and raise OnPropertyChanged so the existing DiffContext compensation in the setter reliably fires before the Changes tab materializes.
1 parent bdcf335 commit 190b4d9

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

src/ViewModels/CommitDetail.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public int ActiveTabIndex
4040
if (value != _sharedData.ActiveTabIndex)
4141
{
4242
_sharedData.ActiveTabIndex = value;
43+
OnPropertyChanged(nameof(ActiveTabIndex));
4344

4445
if (value == 1 && DiffContext == null && _selectedChanges is { Count: 1 })
4546
DiffContext = new DiffContext(_repo.FullPath, new Models.DiffOption(_commit, _selectedChanges[0]));

src/Views/CommitDetail.axaml.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Avalonia;
77
using Avalonia.Controls;
88
using Avalonia.Input;
9-
using Avalonia.LogicalTree;
109
using Avalonia.Platform.Storage;
1110
using Avalonia.VisualTree;
1211

@@ -532,11 +531,8 @@ private void OnChangeDoubleTapped(object sender, TappedEventArgs e)
532531
{
533532
if (DataContext is ViewModels.CommitDetail detail && sender is Grid { DataContext: Models.Change change })
534533
{
535-
var tabControl = this.FindLogicalDescendantOfType<TabControl>();
536-
if (tabControl != null)
537-
tabControl.SelectedIndex = 1;
538-
539534
detail.SelectedChanges = new() { change };
535+
detail.ActiveTabIndex = 1;
540536
}
541537

542538
e.Handled = true;

0 commit comments

Comments
 (0)