mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-24 10:50:52 +08:00
ux: auto-focus commits list box and select the first commit on startup
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -129,9 +129,11 @@ namespace SourceGit.ViewModels
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var commits = await new Commands.QueryCommitsForInteractiveRebase(repoPath, on.SHA).GetResultAsync().ConfigureAwait(false);
|
||||
var list = new List<InteractiveRebaseItem>();
|
||||
var commits = await new Commands.QueryCommitsForInteractiveRebase(repoPath, on.SHA)
|
||||
.GetResultAsync()
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var list = new List<InteractiveRebaseItem>();
|
||||
for (var i = 0; i < commits.Count; i++)
|
||||
{
|
||||
var c = commits[i];
|
||||
@@ -141,6 +143,8 @@ namespace SourceGit.ViewModels
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
Items.AddRange(list);
|
||||
if (list.Count > 0)
|
||||
SelectedItem = list[0];
|
||||
IsLoading = false;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
Background="{DynamicResource Brush.Contents}"
|
||||
ItemsSource="{Binding Items}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
|
||||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Grid.IsSharedSizeScope="True">
|
||||
|
||||
@@ -5,6 +5,7 @@ using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
@@ -73,6 +74,14 @@ namespace SourceGit.Views
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnLoaded(RoutedEventArgs e)
|
||||
{
|
||||
base.OnLoaded(e);
|
||||
|
||||
var list = this.FindDescendantOfType<InteractiveRebaseListBox>();
|
||||
list?.Focus();
|
||||
}
|
||||
|
||||
private void CloseWindow(object _1, RoutedEventArgs _2)
|
||||
{
|
||||
Close();
|
||||
|
||||
Reference in New Issue
Block a user