[PT Run] If only delayed results available, select first (#14209)

This commit is contained in:
Stefan Markovic
2021-11-02 14:04:17 +01:00
committed by GitHub
parent 3dc85595b1
commit e6a7f9193b

View File

@@ -579,6 +579,8 @@ namespace PowerLauncher.ViewModel
UpdateResultsListViewAfterQuery(queryText); UpdateResultsListViewAfterQuery(queryText);
} }
bool noInitialResults = numResults == 0;
// Run the slower query of the DelayedExecution plugins // Run the slower query of the DelayedExecution plugins
currentCancellationToken.ThrowIfCancellationRequested(); currentCancellationToken.ThrowIfCancellationRequested();
Parallel.ForEach(plugins, (plugin) => Parallel.ForEach(plugins, (plugin) =>
@@ -612,7 +614,7 @@ namespace PowerLauncher.ViewModel
} }
currentCancellationToken.ThrowIfCancellationRequested(); currentCancellationToken.ThrowIfCancellationRequested();
UpdateResultsListViewAfterQuery(queryText, true); UpdateResultsListViewAfterQuery(queryText, noInitialResults, true);
} }
} }
} }
@@ -654,7 +656,7 @@ namespace PowerLauncher.ViewModel
} }
} }
private void UpdateResultsListViewAfterQuery(string queryText, bool isDelayedInvoke = false) private void UpdateResultsListViewAfterQuery(string queryText, bool noInitialResults = false, bool isDelayedInvoke = false)
{ {
Application.Current.Dispatcher.BeginInvoke(new Action(() => Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{ {
@@ -667,9 +669,13 @@ namespace PowerLauncher.ViewModel
if (Results.Results.Count > 0) if (Results.Results.Count > 0)
{ {
Results.Visibility = Visibility.Visible; Results.Visibility = Visibility.Visible;
if (!isDelayedInvoke) if (!isDelayedInvoke || noInitialResults)
{ {
Results.SelectedIndex = 0; Results.SelectedIndex = 0;
if (noInitialResults)
{
Results.SelectedItem = Results.Results.FirstOrDefault();
}
} }
} }
else else