diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index e4f601fdf8..f1bc784892 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -1348,9 +1348,9 @@ - + - + diff --git a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs index 243e10145e..5e576c563c 100644 --- a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs +++ b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs @@ -5,6 +5,7 @@ using System; using System.ComponentModel; using System.Linq; +using System.Reactive.Linq; using System.Runtime.InteropServices; using System.Timers; using System.Windows; @@ -159,7 +160,14 @@ namespace PowerLauncher SearchBox.QueryTextBox.DataContext = _viewModel; SearchBox.QueryTextBox.PreviewKeyDown += Launcher_KeyDown; - SearchBox.QueryTextBox.TextChanged += QueryTextBox_TextChanged; + + Observable.FromEventPattern( + add => SearchBox.QueryTextBox.TextChanged += add, + remove => SearchBox.QueryTextBox.TextChanged -= remove) + .Do(@event => ClearAutoCompleteText((TextBox)@event.Sender)) + .Throttle(TimeSpan.FromMilliseconds(150)) + .Do(@event => Dispatcher.InvokeAsync(() => PerformSearchQuery((TextBox)@event.Sender))) + .Subscribe(); // Set initial language flow direction SearchBox_UpdateFlowDirection(); @@ -413,7 +421,7 @@ namespace PowerLauncher // To populate the AutoCompleteTextBox as soon as the selection is changed or set. // Setting it here instead of when the text is changed as there is a delay in executing the query and populating the result - if (_viewModel.Results != null) + if (_viewModel.Results != null && !string.IsNullOrEmpty(SearchBox.QueryTextBox.Text)) { SearchBox.AutoCompleteTextBlock.Text = MainViewModel.GetAutoCompleteText( _viewModel.Results.SelectedIndex, @@ -422,9 +430,8 @@ namespace PowerLauncher } } - private void QueryTextBox_TextChanged(object sender, TextChangedEventArgs e) + private void ClearAutoCompleteText(TextBox textBox) { - var textBox = (TextBox)sender; var text = textBox.Text; var autoCompleteText = SearchBox.AutoCompleteTextBlock.Text; @@ -432,6 +439,11 @@ namespace PowerLauncher { SearchBox.AutoCompleteTextBlock.Text = string.Empty; } + } + + private void PerformSearchQuery(TextBox textBox) + { + var text = textBox.Text; if (_isTextSetProgrammatically) { diff --git a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj index 0cc2a7069d..6ccc39a725 100644 --- a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj +++ b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj @@ -88,6 +88,7 @@ +