feat(ui): auto-select first changed file in diff modal
This commit is contained in:
@@ -152,5 +152,18 @@ public sealed partial class WorktreeModalViewModel : ViewModelBase
|
|||||||
if (parent == null) Root.Add(leaf);
|
if (parent == null) Root.Add(leaf);
|
||||||
else parent.Children.Add(leaf);
|
else parent.Children.Add(leaf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SelectedNode = FindFirstLeaf(Root);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WorktreeNodeViewModel? FindFirstLeaf(IEnumerable<WorktreeNodeViewModel> nodes)
|
||||||
|
{
|
||||||
|
foreach (var n in nodes)
|
||||||
|
{
|
||||||
|
if (!n.IsDirectory) return n;
|
||||||
|
var nested = FindFirstLeaf(n.Children);
|
||||||
|
if (nested is not null) return nested;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user