Skip to content

Commit 2f06b9e

Browse files
committed
enhance: use App.GetLauncher() instead of FindAncestorOfType
Signed-off-by: leo <longshuang@msn.cn>
1 parent f356a7b commit 2f06b9e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Views/RepositoryCommandPaletteTextBox.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
2+
23
using Avalonia;
34
using Avalonia.Controls;
45
using Avalonia.Input;
5-
using Avalonia.VisualTree;
66

77
namespace SourceGit.Views
88
{
@@ -14,9 +14,8 @@ protected override void OnKeyDown(KeyEventArgs e)
1414
{
1515
if (e.Key == Key.Back && string.IsNullOrEmpty(Text))
1616
{
17-
var launcherView = this.FindAncestorOfType<Launcher>(false);
18-
if (launcherView is { DataContext: ViewModels.Launcher launcher } &&
19-
launcher.ActivePage is { Data: ViewModels.Repository repo })
17+
var launcher = App.GetLauncher();
18+
if (launcher is { ActivePage: { Data: ViewModels.Repository repo } })
2019
{
2120
launcher.CommandPalette = new ViewModels.RepositoryCommandPalette(repo);
2221
e.Handled = true;

0 commit comments

Comments
 (0)