diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs index c023c3daae..af57c0f189 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs @@ -66,6 +66,8 @@ public partial class SettingsModel : ObservableObject public EscapeKeyBehavior EscapeKeyBehaviorSetting { get; set; } = EscapeKeyBehavior.ClearSearchFirstThenGoBack; + public bool ClearSearchOnGoHome { get; set; } = true; + public UserTheme Theme { get; set; } = UserTheme.Default; public ColorizationMode ColorizationMode { get; set; } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs index 947a025e69..a667f9f5d5 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsViewModel.cs @@ -144,6 +144,16 @@ public partial class SettingsViewModel : INotifyPropertyChanged } } + public bool ClearSearchOnGoHome + { + get => _settings.ClearSearchOnGoHome; + set + { + _settings.ClearSearchOnGoHome = value; + Save(); + } + } + public int AutoGoBackIntervalIndex { get diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs index ca27af4719..fdbb575802 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/SearchBar.xaml.cs @@ -421,7 +421,13 @@ public sealed partial class SearchBar : UserControl, } } - public void Receive(GoHomeMessage message) => ClearSearch(); + public void Receive(GoHomeMessage message) + { + if (Settings.ClearSearchOnGoHome) + { + ClearSearch(); + } + } public void Receive(FocusSearchBoxMessage message) => FilterBox.Focus(Microsoft.UI.Xaml.FocusState.Programmatic); diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/AppearancePage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/AppearancePage.xaml index 8a66b54d89..b18a04745a 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/AppearancePage.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/AppearancePage.xaml @@ -290,6 +290,10 @@ + + + + diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw b/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw index 996a6202fc..353efbf91e 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw @@ -413,6 +413,12 @@ Right-click to remove the key combination, thereby deactivating the shortcut. Disable animations when switching between pages + + Clear search on go home + + + Clear the search box when navigating back to the home page + Back