Skip to content

CmdPal: Make Calculator Great Again#44594

Merged
michaeljolley merged 5 commits intomicrosoft:mainfrom
jiripolasek:feature/cmdpal-make-calculator-great-again
Jan 29, 2026
Merged

CmdPal: Make Calculator Great Again#44594
michaeljolley merged 5 commits intomicrosoft:mainfrom
jiripolasek:feature/cmdpal-make-calculator-great-again

Conversation

@jiripolasek
Copy link
Copy Markdown
Collaborator

@jiripolasek jiripolasek commented Jan 7, 2026

Summary of the Pull Request

This PR continues the tradition of alphabetical progress. After MBGA, we move on to MCBA — Make Calculator Better Again!

  • Introduces limited automatic correction and completion of expressions.
    • The goal is to allow uninterrupted typing and avoid disruptions when a partially entered expression is temporarily invalid (which previously caused the result to be replaced by an error message or hidden by the fallback).
    • The implementation intentionally aims for a sweet spot:
      • Ignores trailing binary operators.
      • Automatically closes all opened parentheses.
      • It is not exhaustive; for example, incomplete constants or functions may still result in an invalid query.
  • Copy current result to the search bar.
    • Adds an option to copy the current result to the search bar when the user types = at the end of the expression.
    • Adds a new menu item for the same action.
    • Fixes the Save command to also copy the result to the query.
  • Adds support for the factorial(x) function and the x! expression.
    • Factorial calculations are supported up to 170! (limited by double), but display is constrained by decimal conversion and allows direct display of results up to 20!.
  • Adds support for the sign(x) function.
  • Adds support for the π symbol as an alternative to the pi constant.
  • Adds a context menu item to the result list item and fallback that displays the octal representation of the result.
  • Implements beautification of the query:
    • Converts technical symbols such as * or / to × or ÷, respectively.
    • Not enabled for fallbacks for now, since the item text should match the query to keep the score intact.
  • Implements additional normalization of symbols in the query:
    • Percent: , %,
    • Minus: , -, ,
    • Factorial: , !
    • Multiplication: *, ×, , ·, , , , \u2062 (invisible times)
    • Division: /, ÷, , :
  • Allows use of ² and ³ as alternatives to ^2 and ^3.
  • Updates the unit test that was culture sensitive to force en-US output (not an actual fix, but at least it clears false positive for now)
  • Fixes pre-parsing of scientific notation to prevent capturing minus sign as part of it.
  • Fixes normalization/rounding of the result, so it can display small values (the current solution turned it into a string with scientific notation and couldn't parse it back).
  • Updates test with new cases

Pictures? Moving!

Previous behavior:

Screen.Recording.2026-01-07.195332.mp4

New behavior:

Screen.Recording.2026-01-07.195614.mp4

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

@jiripolasek jiripolasek self-assigned this Jan 7, 2026
@jiripolasek jiripolasek added the Product-Command Palette Refers to the Command Palette utility label Jan 7, 2026
Comment thread src/common/CalculatorEngineCommon/ExprtkEvaluator.cpp Fixed
@github-actions

This comment has been minimized.

@jiripolasek
Copy link
Copy Markdown
Collaborator Author

Build fail; unrelated to changes in this PR:

   157>RunVSTest:
            Assert.AreEqual failed. Expected:<1>. Actual:<0>. 
           Stack Trace:
              at Microsoft.CmdPal.Ext.Shell.UnitTests.QueryTests.QueryWithoutHistoryCommand(String command, String exeName) in C:\a\_work\1\s\src\modules\cmdpal\Tests\Microsoft.CmdPal.Ext.Shell.UnitTests\QueryTests.cs:line 97

/azp run

@jiripolasek
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

@michaeljolley michaeljolley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this @jiripolasek

Image

@michaeljolley michaeljolley merged commit 0de2af7 into microsoft:main Jan 29, 2026
11 checks passed
yeelam-gordon pushed a commit that referenced this pull request Jan 31, 2026
## Summary of the Pull Request

This PR continues the tradition of alphabetical progress. After
[MBGA](#41961), we move on to **MCBA — Make Calculator Better Again!**

- Introduces limited automatic correction and completion of expressions.
- The goal is to allow uninterrupted typing and avoid disruptions when a
partially entered expression is temporarily invalid (which previously
caused the result to be replaced by an error message or hidden by the
fallback).
  - The implementation intentionally aims for a sweet spot:
    - Ignores trailing binary operators.
    - Automatically closes all opened parentheses.
- It is not exhaustive; for example, incomplete constants or functions
may still result in an invalid query.
- Copy current result to the search bar.
- Adds an option to copy the current result to the search bar when the
user types `=` at the end of the expression.
  - Adds a new menu item for the same action.
  - Fixes the **Save** command to also copy the result to the query.
- Adds support for the `factorial(x)` function and the `x!` expression.
- Factorial calculations are supported up to `170!` (limited by
`double`), but display is constrained by decimal conversion and allows
direct display of results up to `20!`.
- Adds support for the `sign(x)` function.
- Adds support for the `π` symbol as an alternative to the `pi`
constant.
- Adds a context menu item to the result list item and fallback that
displays the octal representation of the result.
- Implements beautification of the query:
- Converts technical symbols such as `*` or `/` to `×` or `÷`,
respectively.
- Not enabled for fallbacks for now, since the item text should match
the query to keep the score intact.
- Implements additional normalization of symbols in the query:
  - Percent: `%`, `%`, `﹪`
  - Minus: `−`, `-`, `–`, `—`
  - Factorial: `!`, `!`
- Multiplication: `*`, `×`, `∗`, `·`, `⋅`, `✕`, `✖`, `\u2062` (invisible
times)
  - Division: `/`, `÷`, `➗`, `:`
- Allows use of `²` and `³` as alternatives to `^2` and `^3`.
- Updates the unit test that was culture sensitive to force en-US output
(not an actual fix, but at least it clears false positive for now)
- Fixes pre-parsing of scientific notation to prevent capturing minus
sign as part of it.
- Fixes normalization/rounding of the result, so it can display small
values (the current solution turned it into a string with scientific
notation and couldn't parse it back).
- Updates test with new cases

## Pictures? Moving!

Previous behavior:


https://github.com/user-attachments/assets/ebcdcd85-797a-44f9-a8b1-a0f2f33c6b42

New behavior:


https://github.com/user-attachments/assets/5bd94663-a0d0-4d7d-8032-1030e79926c3





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

- [x] Closes: #43481
- [x] Closes: #43460
- [x] Closes: #42078
- [x] Closes: #41839
- [x] Closes: #39659
- [x] Closes: #40502
- [x] Related to: #41715
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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
- [ ] **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
@vanzue vanzue added this to the PowerToys 0.97 milestone Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment