mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Merging main
This commit is contained in:
@@ -34,11 +34,11 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
private readonly AppStateModel _appStateModel;
|
private readonly AppStateModel _appStateModel;
|
||||||
private List<Scored<IListItem>>? _filteredItems;
|
private List<Scored<IListItem>>? _filteredItems;
|
||||||
private List<Scored<IListItem>>? _filteredApps;
|
private List<Scored<IListItem>>? _filteredApps;
|
||||||
private List<Scored<IListItem>>? _fallbackItems;
|
|
||||||
|
|
||||||
// Keep as IEnumerable for deferred execution. Fallback item titles are updated
|
// Keep as IEnumerable for deferred execution. Fallback item titles are updated
|
||||||
// asynchronously, so scoring must happen lazily when GetItems is called.
|
// asynchronously, so scoring must happen lazily when GetItems is called.
|
||||||
private IEnumerable<Scored<IListItem>>? _scoredFallbackItems;
|
private IEnumerable<Scored<IListItem>>? _scoredFallbackItems;
|
||||||
|
private IEnumerable<Scored<IListItem>>? _fallbackItems;
|
||||||
private bool _includeApps;
|
private bool _includeApps;
|
||||||
private bool _filteredItemsIncludesApps;
|
private bool _filteredItemsIncludesApps;
|
||||||
private int _appResultLimit = 10;
|
private int _appResultLimit = 10;
|
||||||
@@ -166,7 +166,7 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
_filteredItems,
|
_filteredItems,
|
||||||
_scoredFallbackItems?.ToList(),
|
_scoredFallbackItems?.ToList(),
|
||||||
_filteredApps,
|
_filteredApps,
|
||||||
_fallbackItems,
|
_fallbackItems?.ToList(),
|
||||||
_appResultLimit);
|
_appResultLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -386,6 +386,13 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_scoredFallbackItems = ListHelpers.FilterListWithScores<IListItem>(newFallbacksForScoring ?? [], SearchText, scoreItem);
|
||||||
|
|
||||||
|
if (token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Func<string, IListItem, int> scoreFallbackItem = (a, b) => { return ScoreFallbackItem(a, b, _settings.FallbackRanks); };
|
Func<string, IListItem, int> scoreFallbackItem = (a, b) => { return ScoreFallbackItem(a, b, _settings.FallbackRanks); };
|
||||||
_fallbackItems = [.. ListHelpers.FilterListWithScores<IListItem>(newFallbacks ?? [], SearchText, scoreFallbackItem)];
|
_fallbackItems = [.. ListHelpers.FilterListWithScores<IListItem>(newFallbacks ?? [], SearchText, scoreFallbackItem)];
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,24 @@ internal static class MainListPageResultFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
int len1 = filteredItems?.Count ?? 0;
|
int len1 = filteredItems?.Count ?? 0;
|
||||||
int len2 = scoredFallbackItems?.Count ?? 0;
|
|
||||||
|
// Scored or not, fallbacks may contain empty items that we want to skip.
|
||||||
|
int len2 = GetNonEmptyFallbackItemsCount(scoredFallbackItems);
|
||||||
|
|
||||||
// Apps are pre-sorted, so we just need to take the top N, limited by appResultLimit.
|
// Apps are pre-sorted, so we just need to take the top N, limited by appResultLimit.
|
||||||
int len3 = Math.Min(filteredApps?.Count ?? 0, appResultLimit);
|
int len3 = Math.Min(filteredApps?.Count ?? 0, appResultLimit);
|
||||||
|
|
||||||
|
int nonEmptyFallbackCount = GetNonEmptyFallbackItemsCount(fallbackItems);
|
||||||
|
|
||||||
// Allocate the exact size of the result array.
|
// Allocate the exact size of the result array.
|
||||||
int totalCount = len1 + len2 + len3 + GetNonEmptyFallbackItemsCount(fallbackItems);
|
int totalCount = len1 + len2 + len3 + nonEmptyFallbackCount;
|
||||||
|
|
||||||
|
// If there are non-empty fallbacks, we'll be adding a separator "Section"
|
||||||
|
if (nonEmptyFallbackCount > 0)
|
||||||
|
{
|
||||||
|
totalCount++;
|
||||||
|
}
|
||||||
|
|
||||||
var result = new IListItem[totalCount];
|
var result = new IListItem[totalCount];
|
||||||
|
|
||||||
// Three-way stable merge of already-sorted lists.
|
// Three-way stable merge of already-sorted lists.
|
||||||
@@ -122,6 +133,9 @@ internal static class MainListPageResultFactory
|
|||||||
// always at the end of the list and are sorted by user settings.
|
// always at the end of the list and are sorted by user settings.
|
||||||
if (fallbackItems is not null)
|
if (fallbackItems is not null)
|
||||||
{
|
{
|
||||||
|
// Create the fallbacks section header
|
||||||
|
result[writePos++] = new Separator(Properties.Resources.fallbacks);
|
||||||
|
|
||||||
for (int i = 0; i < fallbackItems.Count; i++)
|
for (int i = 0; i < fallbackItems.Count; i++)
|
||||||
{
|
{
|
||||||
var item = fallbackItems[i].Item;
|
var item = fallbackItems[i].Item;
|
||||||
@@ -143,7 +157,7 @@ internal static class MainListPageResultFactory
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < fallbackItems.Count; i++)
|
for (int i = 0; i < fallbackItems.Count; i++)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(fallbackItems[i].Item.Title))
|
if (!string.IsNullOrWhiteSpace(fallbackItems[i].Item.Title))
|
||||||
{
|
{
|
||||||
fallbackItemsCount++;
|
fallbackItemsCount++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ namespace Microsoft.CmdPal.UI.ViewModels.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Create a new extension.
|
/// Looks up a localized string similar to Create extension.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string builtin_create_extension_title {
|
public static string builtin_create_extension_title {
|
||||||
get {
|
get {
|
||||||
@@ -349,7 +349,7 @@ namespace Microsoft.CmdPal.UI.ViewModels.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Creates a project for a new Command Palette extension.
|
/// Looks up a localized string similar to Generate a new Command Palette extension project.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string builtin_new_extension_subtitle {
|
public static string builtin_new_extension_subtitle {
|
||||||
get {
|
get {
|
||||||
@@ -358,7 +358,7 @@ namespace Microsoft.CmdPal.UI.ViewModels.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Open Settings.
|
/// Looks up a localized string similar to Open Command Palette settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string builtin_open_settings_name {
|
public static string builtin_open_settings_name {
|
||||||
get {
|
get {
|
||||||
@@ -366,15 +366,6 @@ namespace Microsoft.CmdPal.UI.ViewModels.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Open Command Palette settings.
|
|
||||||
/// </summary>
|
|
||||||
public static string builtin_open_settings_subtitle {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("builtin_open_settings_subtitle", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Exit Command Palette.
|
/// Looks up a localized string similar to Exit Command Palette.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -437,5 +428,14 @@ namespace Microsoft.CmdPal.UI.ViewModels.Properties {
|
|||||||
return ResourceManager.GetString("builtin_settings_extension_n_extensions_installed", resourceCulture);
|
return ResourceManager.GetString("builtin_settings_extension_n_extensions_installed", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Fallbacks.
|
||||||
|
/// </summary>
|
||||||
|
public static string fallbacks {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("fallbacks", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,4 +242,7 @@
|
|||||||
<data name="builtin_settings_appearance_pick_background_image_title" xml:space="preserve">
|
<data name="builtin_settings_appearance_pick_background_image_title" xml:space="preserve">
|
||||||
<value>Pick background image</value>
|
<value>Pick background image</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="fallbacks" xml:space="preserve">
|
||||||
|
<value>Fallbacks</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user