Niels LauteandCopilot App faceb908fe fix(settings-ui): reject empty normalized search queries (#50531)
<!-- 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

Prevent Settings search from passing queries that normalize to empty or
whitespace-only text into fuzzy matching, and make the shared matcher
return its existing no-match result for whitespace-only queries.

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

- [x] **Communication:** Scoped to the requested atomic Settings
search-safety audit follow-up; submitted as a draft.
- [x] **Tests:** Added focused regression coverage; all 46 selected
tests pass.
- [x] **Localization:** No new user-facing strings; normalization and
existing localized search behavior are unchanged.

Issue closure, development/user documentation, and new-binary checklist
items are N/A. No new projects, dependencies, binaries, or persisted
settings changes.

<!-- 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

**Trigger:** A query consisting of U+00A8 (spacing diaeresis) passes the
initial whitespace check in
`src\settings-ui\Settings.UI\Services\SearchIndexService.cs`. FormKD
normalization decomposes it into U+0020 plus a combining mark; removing
nonspacing marks leaves a single space. Previously,
`src\common\Common.Search\FuzzSearch\StringMatcher.cs` checked only for
null/empty input before trimming, then indexed the first element of an
empty token array. With a populated search index, the resulting
`IndexOutOfRangeException` can propagate through `Parallel.ForEach` to
the live search handler, which catches cancellation only. This is a
source/unit-test finding, not a claim of a reproduced live application
crash.

The Settings service now returns no results after normalization when no
searchable text remains. The shared matcher rejects
null/empty/whitespace queries before its per-start-index matching loop,
preventing empty trimmed/tokenized input from reaching the indexed
access. Both use existing no-match behavior rather than adding an
exception catch.

**Shared-caller risk:** Common.Search is also used by Shortcut Guide and
the Command Palette PowerToys extension. Their existing blank-query
handling remains unchanged, as do the matching algorithm, separators,
scoring, highlighting, and case options for nonempty queries. No public
API signature changes. `NormalizeString` becomes internal solely for
direct coverage through the existing Settings test friend assembly.

Tests are in the existing
`src\settings-ui\Settings.UI.UnitTests\Search\StringMatcherTests.cs` and
`src\settings-ui\Settings.UI.UnitTests\Search\SearchIndexServiceTests.cs`;
there is no standalone Common.Search test project on current main. The
service fixture supplies a nonempty in-memory index, restores it
afterward, and does not load Settings resources or change user settings.

This PR deliberately excludes expander-result filtering and prebuilt
search-index generation/embedding changes. It does not auto-close the
different search-crash reports #41817 or #47118.

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

- Ran the repository first-build prerequisite
`tools\build\build-essentials.cmd -Platform x64 -Configuration Release`
after the fresh worktree reported missing NuGet assets; restore and
essentials completed successfully.
- Built `Settings.UI.UnitTests` in Release x64 using
`tools\build\build.ps1` with the worktree `SolutionDir`; exit code 0.
- Ran the existing Microsoft.Testing.Platform runner with `--filter
"FullyQualifiedName~Settings.UI.UnitTests.Search"
--minimum-expected-tests 46 --report-trx`: **46 passed, 0 failed, 0
skipped**.
- Covered null/empty/ASCII whitespace, Unicode spaces, U+00A8
compatibility normalization, combining-only queries, both Search
overloads with a nonempty index, both case options,
ordinary/padded/multiword queries, unchanged scores/highlights,
exact-match ranking, and accented/fullwidth normalization.
- Did not launch or modify the installed/running PowerToys instance or
user settings.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-03 13:25:39 +08:00
…
…
…
…
…
…
…

Microsoft PowerToys

Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks.

Installation · Documentation · Blog · Release notes

🔨 Utilities

PowerToys includes over 30 utilities to help you customize and optimize your Windows experience:

Advanced Paste icon Advanced Paste Always on Top icon Always on Top Awake icon Awake
Color Picker icon Color Picker Command Not Found icon Command Not Found Command Palette icon Command Palette
Crop and Lock icon Crop And Lock Environment Variables icon Environment Variables FancyZones icon FancyZones
File Explorer Add-ons icon File Explorer Add-ons File Locksmith icon File Locksmith Grab And Move icon Grab And Move
Hosts File Editor icon Hosts File Editor Image Resizer icon Image Resizer Keyboard Manager icon Keyboard Manager
Light Switch icon Light Switch Mouse Utilities icon Mouse Utilities Mouse Without Borders icon Mouse Without Borders
New+ icon New+ Peek icon Peek PowerDisplay icon PowerDisplay
PowerRename icon PowerRename PowerToys Run icon PowerToys Run Quick Accent icon Quick Accent
Registry Preview icon Registry Preview Screen Ruler icon Screen Ruler Shortcut Guide icon Shortcut Guide
Text Extractor icon Text Extractor Window Hopper icon Window Hopper Workspaces icon Workspaces
ZoomIt icon ZoomIt

📦 Installation

For detailed installation instructions and system requirements, visit the installation docs.

But to get started quickly, choose one of the installation methods below:

Download the .exe file from GitHub

Go to the PowerToys GitHub releases, scroll down and select Assets to reveal the installation files, and choose the one that matches your architecture and install scope. For most devices, that would be x64 per-user.

Microsoft Store
You can easily install PowerToys from the Microsoft Store:

WinGet
Download PowerToys from [WinGet](https://github.com/microsoft/winget-cli#installing-the-client). Updating PowerToys via winget will respect the current PowerToys installation scope. To install PowerToys, run the following command from the command line / PowerShell:
  • User scope installer (default)
winget install Microsoft.PowerToys -s winget
  • Machine-wide scope installer
winget install --scope machine Microsoft.PowerToys -s winget
Other methods
There are [community driven install methods](https://learn.microsoft.com/windows/powertoys/install#community-driven-install-tools) such as Chocolatey and Scoop. If these are your preferred install solutions, you can find the install instructions there.

✨ What's new?

What's new image

To see what's new, check out the release notes.

🛣️ Roadmap

For v0.103, we're working on a new Awake flyout, improving Screen Ruler, and continuing to modernize more utilities with WinUI 3.

❤️ PowerToys Community

The PowerToys team is extremely grateful to have the support of an amazing active community. The work you do is incredibly important. PowerToys wouldn't be nearly what it is today without your help filing bugs, updating documentation, guiding the design, or writing features. We want to say thank you and take time to recognize your work. Your contributions and feedback improve PowerToys month after month!

Contributing

This project welcomes contributions of all types. Besides coding features / bug fixes, other ways to assist include spec writing, design, documentation, and finding bugs. We are excited to work with the power user community to build a set of tools for helping you get the most out of Windows. We ask that before you start work on a feature that you would like to contribute, please read our Contributor's Guide. We would be happy to work with you to figure out the best approach, provide guidance and mentorship throughout feature development, and help avoid any wasted or duplicate effort. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you grant us the rights to use your contribution and that you have permission to do so. For guidance on developing for PowerToys, please read the developer docs for a detailed breakdown. This includes how to setup your computer to compile.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct.

Privacy statement

The application logs basic diagnostic data (telemetry). For more privacy information and what we collect, see our PowerToys Data and Privacy documentation.

Languages
C 39.4%
C# 31.9%
C++ 13.5%
JavaScript 12.4%
PowerShell 2.5%
Other 0.3%