[CmdPal > Ext] Use empty content for WindowWalker, Windows Settings and Windows Search (#40722)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

This PR improves the behavior of CmdPal on empty or wrong search query
for the following exts:
- Window Walker
- Windows Settings
- Windows Search (indexer)

### Window Walker
<img width="795" height="482" alt="image"
src="https://github.com/user-attachments/assets/352a122d-2b8f-45be-bf49-6a56f6ca0848"
/>

### Windows Settings - Empty query
<img width="796" height="485" alt="image"
src="https://github.com/user-attachments/assets/12f193b3-22c5-45d8-89c0-bba5740da62b"
/>

### Windows Settings - No search match
<img width="855" height="483" alt="image"
src="https://github.com/user-attachments/assets/e521f63d-65ae-4b93-992d-2bb0a11edaa7"
/>

### Windows search (indexer)
<img width="796" height="483" alt="image"
src="https://github.com/user-attachments/assets/c2e6a218-de2b-4657-a9e7-9def26c9258e"
/>



<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] **Closes:** #40614 , #38293 , #40565
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

---------

Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Mike Griese <migrie@microsoft.com>
This commit is contained in:
Heiko
2025-08-18 18:22:26 +02:00
committed by GitHub
parent 6acb793184
commit 65b752b3ff
12 changed files with 141 additions and 26 deletions

View File

@@ -21,6 +21,8 @@ internal sealed partial class IndexerPage : DynamicListPage, IDisposable
private string initialQuery = string.Empty;
private bool _isEmptyQuery = true;
public IndexerPage()
{
Id = "com.microsoft.indexer.fileSearch";
@@ -43,15 +45,19 @@ internal sealed partial class IndexerPage : DynamicListPage, IDisposable
disposeSearchEngine = false;
}
public override ICommandItem EmptyContent => GetEmptyContent();
public override void UpdateSearchText(string oldSearch, string newSearch)
{
if (oldSearch != newSearch && newSearch != initialQuery)
{
_ = Task.Run(() =>
{
_isEmptyQuery = string.IsNullOrWhiteSpace(newSearch);
Query(newSearch);
LoadMore();
initialQuery = string.Empty;
OnPropertyChanged(nameof(EmptyContent));
initialQuery = null;
});
}
}
@@ -68,6 +74,16 @@ internal sealed partial class IndexerPage : DynamicListPage, IDisposable
RaiseItemsChanged(_indexerListItems.Count);
}
private CommandItem GetEmptyContent()
{
return new CommandItem(new NoOpCommand())
{
Icon = Icon,
Title = _isEmptyQuery ? Resources.Indexer_Subtitle : Resources.Indexer_NoResultsMessage,
Subtitle = Resources.Indexer_NoResultsMessageTip,
};
}
private void Query(string query)
{
++_queryCookie;

View File

@@ -61,7 +61,7 @@ namespace Microsoft.CmdPal.Ext.Indexer.Properties {
}
/// <summary>
/// Looks up a localized string similar to Actions.
/// Looks up a localized string similar to Actions....
/// </summary>
internal static string Indexer_Command_Actions {
get {
@@ -177,6 +177,24 @@ namespace Microsoft.CmdPal.Ext.Indexer.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to No items found.
/// </summary>
internal static string Indexer_NoResultsMessage {
get {
return ResourceManager.GetString("Indexer_NoResultsMessage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Tip: Improve your search result using filters like in Windows Explorer. (For example: type:directory).
/// </summary>
internal static string Indexer_NoResultsMessageTip {
get {
return ResourceManager.GetString("Indexer_NoResultsMessageTip", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Search for files and folders....
/// </summary>

View File

@@ -180,4 +180,10 @@
<data name="Indexer_fallback_searchPage_title" xml:space="preserve">
<value>Search for "{0}" in files</value>
</data>
<data name="Indexer_NoResultsMessage" xml:space="preserve">
<value>No items found</value>
</data>
<data name="Indexer_NoResultsMessageTip" xml:space="preserve">
<value>Tip: Refine your search using filters, just like in File Explorer (e.g., type:directory).</value>
</data>
</root>