mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-09-01 19:51:34 +02:00
## Description Fixes #49285 This PR fixes three documentation files with broken links or incorrect source file references: ### 1. `doc/devdocs/modules/fileexploreraddons.md` — broken source code link The "Source code folder" link pointed to `src/modules/fileexplorerpreview`, which does not exist in the repository. Changed to `src/modules/previewpane` (the actual directory). ### 2. `doc/devdocs/modules/launcher/plugins/calculator.md` — broken unit test links (10 occurrences) All 10 links in the "Unit Tests" section pointed to `Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests` (plural), but the actual test project directory is `Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest` (singular). All link references have been corrected. ### 3. `doc/devdocs/core/runner.md` — incorrect file reference The "Centralized Keyboard Hook" section referenced `centralized_keyboard_hook.cpp`, but the actual file is `centralized_kb_hook.cpp` (at `src/runner/centralized_kb_hook.cpp`). ## Validation Each fix was verified against the actual repository structure: | Fix | Verified path exists | |-----|---------------------| | `fileexploreraddons.md` | `src/modules/previewpane/` (contains `powerpreview/` subproject) | | `calculator.md` | `src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/` (contains `BracketHelperTests.cs`, `ExtendedCalculatorParserTests.cs`, `NumberTranslatorTests.cs`, `QueryTests.cs`) | | `runner.md` | `src/runner/centralized_kb_hook.cpp` | ## PR Checklist - [x] Docs-only change — no code or tests affected - [x] Links verified against actual repository structure
4.9 KiB
4.9 KiB
Calculator Plugin
The Calculator plugin as the name suggests is used to perform calculations on the user entered query.
Optional plugin settings
-
We have the following settings that the user can configure to change the behavior of the plugin:
Key Default value Name Description InputUseEnglishFormatfalseUse English (United States) number format for input Ignores your system setting and expects numbers in the format '1,000.50' OutputUseEnglishFormatfalseUse English (United States) number format for output Ignores your system setting and returns numbers in the format '1000.50' -
The optional plugin settings are implemented via the
ISettingProviderinterface fromWox.Pluginproject. All available settings for the plugin are defined in theMainclass of the plugin.
Technical details
BracketHelper
- This helper validates the bracket usage in the input string.
CalculateHelper
- The
CalculateHelper.csclass checks to see if the user entered query is a valid input to the calculator and only if the input is valid does it perform the operation.- It does so by matching the user query to a valid regex.
- This class also handles some human multiplication expression like
2(1+2)and(2+3)(3+4)in order to be computed byMageslib.- It does so by matching some regex and inserting
'*'where appropriate, e.g:2(1+2) -> 2 * (1+2) - It takes into account the combination of numbers (
num), constants (const), functions (func) and expressions in parentheses ((exp)). - The blank spaces between them are also considered.
- Some combinations were not handled as they are not common such as
'const num'or'func const'
- It does so by matching some regex and inserting
CalculateEngine
- The main computation is done in the
CalculateEngine.csfile using theMageslibrary.
var result = CalculateEngine.Interpret(query.Search, CultureInfo.CurrentUICulture);
CalculateResult
- The class which encapsulates the result of the computation.
- It comprises of the
ResultandRoundedResultproperties.
ErrorHandler
- The class which encapsulates the code to log errors and format the user message.
- It returns an error result if the user searches with the activation command. This error result is shown to the user.
Score
The score of each result from the calculator plugin is 300.
Unit Tests
We have a Unit Test project that executes various test to ensure that the plugin works as expected.
BracketHelperTests
- The
BracketHelperTests.csclass contains tests to validate that brackets are handled correctly.
ExtendedCalculatorParserTests
- The
ExtendedCalculatorParserTests.csclass contains tests to validate that the input is parsed correctly and the result is correct.
NumberTranslatorTests
- The
NumberTranslatorTests.csclass contains tests to validate that each number is converted correctly based on the defined locals.
QueryTests
- The
QueryTests.csclass contains tests to validate that the user gets the correct results when searching.
