diff --git a/src/Views/LauncherPageSwitcher.axaml.cs b/src/Views/LauncherPageSwitcher.axaml.cs index 15c25075..8595af22 100644 --- a/src/Views/LauncherPageSwitcher.axaml.cs +++ b/src/Views/LauncherPageSwitcher.axaml.cs @@ -32,14 +32,28 @@ namespace SourceGit.Views private void OnSearchBoxKeyDown(object sender, KeyEventArgs e) { - if (e.Key == Key.Down && PagesListBox.ItemCount > 0) + if (PagesListBox.ItemCount == 0) + return; + + if (e.Key == Key.Down) { PagesListBox.Focus(NavigationMethod.Directional); - if (PagesListBox.SelectedIndex < 0) - PagesListBox.SelectedIndex = 0; - else if (PagesListBox.SelectedIndex < PagesListBox.ItemCount) + if (PagesListBox.SelectedIndex < PagesListBox.ItemCount - 1) PagesListBox.SelectedIndex++; + else + PagesListBox.SelectedIndex = 0; + + e.Handled = true; + } + else if (e.Key == Key.Up) + { + PagesListBox.Focus(NavigationMethod.Directional); + + if (PagesListBox.SelectedIndex > 0) + PagesListBox.SelectedIndex--; + else + PagesListBox.SelectedIndex = PagesListBox.ItemCount - 1; e.Handled = true; } diff --git a/src/Views/WorkspaceSwitcher.axaml.cs b/src/Views/WorkspaceSwitcher.axaml.cs index aaed5056..7b708dd9 100644 --- a/src/Views/WorkspaceSwitcher.axaml.cs +++ b/src/Views/WorkspaceSwitcher.axaml.cs @@ -32,14 +32,28 @@ namespace SourceGit.Views private void OnSearchBoxKeyDown(object sender, KeyEventArgs e) { - if (e.Key == Key.Down && WorkspaceListBox.ItemCount > 0) + if (WorkspaceListBox.ItemCount == 0) + return; + + if (e.Key == Key.Down) { WorkspaceListBox.Focus(NavigationMethod.Directional); - if (WorkspaceListBox.SelectedIndex < 0) - WorkspaceListBox.SelectedIndex = 0; - else if (WorkspaceListBox.SelectedIndex < WorkspaceListBox.ItemCount) + if (WorkspaceListBox.SelectedIndex < WorkspaceListBox.ItemCount - 1) WorkspaceListBox.SelectedIndex++; + else + WorkspaceListBox.SelectedIndex = 0; + + e.Handled = true; + } + else if (e.Key == Key.Up) + { + WorkspaceListBox.Focus(NavigationMethod.Directional); + + if (WorkspaceListBox.SelectedIndex > 0) + WorkspaceListBox.SelectedIndex--; + else + WorkspaceListBox.SelectedIndex = WorkspaceListBox.ItemCount - 1; e.Handled = true; }