Repository navigation
[Screen Ruler] Fix DPI measurement selection issue - #50696
Merged
Yu Leng (moooyo) merged 2 commits intoSep 22, 2026
Merged
Conversation
âĶdoes not go out of sync in the future.
Contributor
There was a problem hiding this comment.
Copilot review overview
ðĒ Approval recommended
The only remaining comment is a non-blocking documentation nit.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes Screen Rulerâs DIP secondary measurement selection and legacy unit migration.
Changes:
- Supports DIP at combo-box index 4.
- Preserves millimetre migration and updates normalization bounds.
- Adds regression tests for normalization and item-count consistency.
| File | Summary |
|---|---|
src/âsettings-ui/âSettings.UI/âViewModels/âMeasureToolViewModel.cs |
Updates measurement normalization and supports DIP index 4. Minor nit: correct the legacy enum value in the comment. |
src/âsettings-ui/âSettings.UI.UnitTests/âViewModelTests/âMeasureTool.cs |
Adds regression coverage for migration and combo-box alignment. |
ðĄ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
|
/azp run |
Yu Leng (moooyo)
approved these changes
Sep 22, 2026
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Kai Tao (vanzue)
approved these changes
Sep 22, 2026
Contributor
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Contributor
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary of the Pull Request
This fixes an issue which prevented the "Device-independent pixels" option from being selected as Screen Ruler's secondary measurement option.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Screen Ruler used to store the secondary measurement unit as the enum value from
MeasureToolCore.MeasurementLogic.Unit:This was changed to store the combo box index, but at the time the combo box only had 4 items with indexes 0 to 3. This crashed the application if a user had Centimetre or Millimetre saved (DIP was not available at the time). In PR #49898 a migration method was added to translate legacy settings values:
(This worked for Centimetre, Millimetre and Inch, but actually broke for Pixel, setting it to Inch accidentally.)
Later, PR #49588 added DIP as the fifth combo box item at index 4 and updated the basic mapping, but did not update the
NormalizeUnitsOfMeasureIndexroutine or increase theMaximumUnitsOfMeasureIndexconst from 3 to 4.The effect of this was that the DIP value was saved as the combo box index of 4, but the normalisation method translated it straight back to 2 - Inch.
Solution
As a value of 4 is ambiguous we must remove the normalise step for it; otherwise DIPs cannot be selected. Legacy users who upgrade from a very old version of PowerToys and who have Centimetres saved will now get DIPs, but this should affect a very small number of individuals.
Note: this will hit us again if the number of combo box entries ever gets to 9, as the 8th entry will get mapped to millimetre. We should remove the
8 => 3line at that point.Validation Steps Performed
Manual tests:
Unit tests:
MaximumUnitsOfMeasureIndexcan no longer deviate from the number of items in the combo box.All unit tests pass: