Fix CmdPal apps extension ignoring the fallback results limit setting (#45716)

## Summary

MainListPage hardcoded _appResultLimit = 10 instead of reading from
AllAppsCommandProvider.TopLevelResultLimit, which correctly parses the
user's SearchResultLimit setting. This meant changing the results limit
in settings had no effect on the apps extension fallback results.

##  Changes

- `MainListPage.cs` — Replaced the hardcoded _appResultLimit = 10 field
with a computed property AppResultLimit that delegates to
AllAppsCommandProvider.TopLevelResultLimit.
- `MainListPageResultFactoryTests.cs` — Added three regression tests:
- `Merge_AppLimitOfOne_ReturnsOnlyTopApp` — verifies limit of 1 returns
only the top app
- `Merge_AppLimitOfZero_ReturnsNoApps` — verifies limit of 0 returns no
apps
- `Merge_AppLimitOfOne_WithOtherResults_AppsAreLimited` — verifies apps
are limited even when mixed with other result types

## Validation

- [X]  Existing tests pass
- [X] New regression tests cover edge cases for the appResultLimit
parameter

## Linked Issues

- Fixes #45654

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Michael Jolley
2026-02-21 18:47:27 -08:00
committed by GitHub
parent ed76886d98
commit fafb582ae2
2 changed files with 72 additions and 2 deletions

View File

@@ -47,7 +47,8 @@ public sealed partial class MainListPage : DynamicListPage,
private bool _includeApps;
private bool _filteredItemsIncludesApps;
private int _appResultLimit = 10;
private int AppResultLimit => AllAppsCommandProvider.TopLevelResultLimit;
private InterlockedBoolean _refreshRunning;
private InterlockedBoolean _refreshRequested;
@@ -190,7 +191,7 @@ public sealed partial class MainListPage : DynamicListPage,
validScoredFallbacks,
_filteredApps,
validFallbacks,
_appResultLimit);
AppResultLimit);
}
}
}

View File

@@ -120,6 +120,75 @@ public partial class MainListPageResultFactoryTests
Assert.AreEqual("A2", result[1].Title);
}
[TestMethod]
public void Merge_AppLimitOfOne_ReturnsOnlyTopApp()
{
var apps = new List<RoScored<IListItem>>
{
S("A1", 100),
S("A2", 90),
S("A3", 80),
};
var result = MainListPageResultFactory.Create(
null,
null,
apps,
null,
appResultLimit: 1);
Assert.AreEqual(1, result.Length);
Assert.AreEqual("A1", result[0].Title);
}
[TestMethod]
public void Merge_AppLimitOfZero_ReturnsNoApps()
{
var apps = new List<RoScored<IListItem>>
{
S("A1", 100),
S("A2", 90),
};
var result = MainListPageResultFactory.Create(
null,
null,
apps,
null,
appResultLimit: 0);
Assert.AreEqual(0, result.Length);
}
[TestMethod]
public void Merge_AppLimitOfOne_WithOtherResults_AppsAreLimited()
{
var filtered = new List<RoScored<IListItem>>
{
S("F1", 100),
S("F2", 50),
};
var apps = new List<RoScored<IListItem>>
{
S("A1", 90),
S("A2", 80),
S("A3", 70),
};
var result = MainListPageResultFactory.Create(
filtered,
null,
apps,
null,
appResultLimit: 1);
Assert.AreEqual(3, result.Length);
Assert.AreEqual("F1", result[0].Title);
Assert.AreEqual("A1", result[1].Title);
Assert.AreEqual("F2", result[2].Title);
}
[TestMethod]
public void Merge_FiltersEmptyFallbacks()
{