Conversation
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Pages/IndexerPage.cs
Outdated
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
I would use even simpler strings myself: Files, Folders, Files and folders. |
This comment has been minimized.
This comment has been minimized.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.resx
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.Designer.cs
Outdated
Show resolved
Hide resolved
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.Unrecognized words (4)dfx These words are not needed and should be removedDFX WorktreeTo accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands... in a clone of the git@github.com:microsoft/PowerToys.git repository curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/c635c2f3f714eec2fcf27b643a1919b9a811ef2e/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/18477177460/attempts/1' &&
git commit -m 'Update check-spelling metadata'If the flagged items are 🤯 false positivesIf items relate to a ...
|
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@michaeljolley LGTM The only issue with this is that Windows treats archives as folders. A bunch of .gz files mixed with folders looked like a mistake at first glance. Tested on Windows 11 25H2, Release, and Release + AOT (after manually merging main to incorporate the fix for filters).
|
Closes #39260 Search for all files & folders, folders only, or files only. Enjoy. https://github.com/user-attachments/assets/43ba93f5-dfc5-4e73-8414-547cf99dcfcf
There was a problem hiding this comment.
Pull Request Overview
This PR adds filter functionality to the Indexer extension in Command Palette, allowing users to filter search results by file type (all files and folders, folders only, or files only).
- Adds three filter options: "Files and folders", "Folders", and "Files"
- Integrates filters into the search query using Windows Search syntax (
kind:foldersandkind:NOT folders) - Changes the
Iconsclass fromsealedtostatic(appropriate since it only contains static members)
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Resources.resx | Adds three new localized string resources for filter labels |
| Resources.Designer.cs | Auto-generated designer code for the new resource strings |
| IndexerPage.cs | Integrates filter functionality, refactors search logic into PerformSearch method, and adds FullSearchString method to append filter keywords |
| SearchFilters.cs | New class defining the available filters (all, folders, files) with appropriate icons |
| Icons.cs | Changes class from sealed to static and adds two new icon definitions for filters |
Files not reviewed (1)
- src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.Designer.cs: Language not supported
| var actualSearch = FullSearchString(newSearch); | ||
| _ = Task.Run(() => | ||
| { | ||
| _isEmptyQuery = string.IsNullOrWhiteSpace(actualSearch); |
There was a problem hiding this comment.
The _isEmptyQuery check now uses actualSearch (which includes filter keywords) instead of the original newSearch input. This means that even when a user hasn't entered any query text, if they've selected the "folders" or "files" filter, _isEmptyQuery will be false because actualSearch will contain "kind:folders" or "kind:NOT folders".
This could affect the EmptyContent property behavior - users might see "no results" message instead of the "no search query" message when they select a filter without entering any search text. Consider checking newSearch directly instead:
_isEmptyQuery = string.IsNullOrWhiteSpace(newSearch);| _isEmptyQuery = string.IsNullOrWhiteSpace(actualSearch); | |
| _isEmptyQuery = string.IsNullOrWhiteSpace(newSearch); |
| var filters = new SearchFilters(); | ||
| filters.PropChanged += Filters_PropChanged; | ||
| Filters = filters; |
There was a problem hiding this comment.
The filter initialization logic (lines 41-43 and 59-61) is duplicated across both constructors. This violates the DRY (Don't Repeat Yourself) principle and could lead to maintenance issues if the initialization logic needs to change.
Consider extracting this to a shared initialization method:
private void InitializeFilters()
{
var filters = new SearchFilters();
filters.PropChanged += Filters_PropChanged;
Filters = filters;
}Then call InitializeFilters(); in both constructors.
| switch (Filters.CurrentFilterId) | ||
| { | ||
| case "folders": | ||
| return $"{query} kind:folders"; | ||
| case "files": | ||
| return $"{query} kind:NOT folders"; | ||
| case "all": | ||
| default: | ||
| return query; |
There was a problem hiding this comment.
The FullSearchString method can produce unintended results when the query is empty or whitespace-only. For example, with the "folders" filter and an empty query, it would return " kind:folders" (note the leading space), and with the "files" filter, it would return " kind:NOT folders". This could lead to unexpected search behavior.
Consider trimming the result or checking if the query is empty before appending the filter:
private string FullSearchString(string query)
{
var trimmedQuery = query?.Trim() ?? string.Empty;
switch (Filters.CurrentFilterId)
{
case "folders":
return string.IsNullOrWhiteSpace(trimmedQuery)
? "kind:folders"
: $"{trimmedQuery} kind:folders";
case "files":
return string.IsNullOrWhiteSpace(trimmedQuery)
? "kind:NOT folders"
: $"{trimmedQuery} kind:NOT folders";
case "all":
default:
return trimmedQuery;
}
}| switch (Filters.CurrentFilterId) | |
| { | |
| case "folders": | |
| return $"{query} kind:folders"; | |
| case "files": | |
| return $"{query} kind:NOT folders"; | |
| case "all": | |
| default: | |
| return query; | |
| var trimmedQuery = query?.Trim() ?? string.Empty; | |
| switch (Filters.CurrentFilterId) | |
| { | |
| case "folders": | |
| return string.IsNullOrWhiteSpace(trimmedQuery) | |
| ? "kind:folders" | |
| : $"{trimmedQuery} kind:folders"; | |
| case "files": | |
| return string.IsNullOrWhiteSpace(trimmedQuery) | |
| ? "kind:NOT folders" | |
| : $"{trimmedQuery} kind:NOT folders"; | |
| case "all": | |
| default: | |
| return trimmedQuery; |
Closes microsoft#39260 Search for all files & folders, folders only, or files only. Enjoy. https://github.com/user-attachments/assets/43ba93f5-dfc5-4e73-8414-547cf99dcfcf

Closes #39260
Search for all files & folders, folders only, or files only.
Enjoy.
Screen.Recording.2025-10-01.160524.mp4