Skip to content

Commit

Permalink
[PT Run] If only delayed results available, select first (#14209)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansjfw committed Nov 2, 2021
1 parent 3dc8559 commit e6a7f91
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ private void QueryResults()
UpdateResultsListViewAfterQuery(queryText);
}
bool noInitialResults = numResults == 0;
// Run the slower query of the DelayedExecution plugins
currentCancellationToken.ThrowIfCancellationRequested();
Parallel.ForEach(plugins, (plugin) =>
Expand Down Expand Up @@ -612,7 +614,7 @@ private void QueryResults()
}
currentCancellationToken.ThrowIfCancellationRequested();
UpdateResultsListViewAfterQuery(queryText, true);
UpdateResultsListViewAfterQuery(queryText, noInitialResults, true);
}
}
}
Expand Down Expand Up @@ -654,7 +656,7 @@ private void QueryResults()
}
}

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(() =>
{
Expand All @@ -667,9 +669,13 @@ private void UpdateResultsListViewAfterQuery(string queryText, bool isDelayedInv
if (Results.Results.Count > 0)
{
Results.Visibility = Visibility.Visible;
if (!isDelayedInvoke)
if (!isDelayedInvoke || noInitialResults)
{
Results.SelectedIndex = 0;
if (noInitialResults)
{
Results.SelectedItem = Results.Results.FirstOrDefault();
}
}
}
else
Expand Down

0 comments on commit e6a7f91

Please sign in to comment.