[PTRun][Calculator]Replace input with result with '=' key (#31391)

* replace input with result

* fix and add test

* add options and use result property
This commit is contained in:
Davide Giacometti
2024-02-20 13:08:54 +01:00
committed by GitHub
parent e573b7a1b1
commit 92c85630a9
8 changed files with 121 additions and 37 deletions

View File

@@ -12,12 +12,12 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
{
public static class ResultHelper
{
public static Result CreateResult(CalculateResult result, string iconPath, CultureInfo culture)
public static Result CreateResult(CalculateResult result, string iconPath, CultureInfo inputCulture, CultureInfo outputCulture)
{
return CreateResult(result.RoundedResult, iconPath, culture);
return CreateResult(result.RoundedResult, iconPath, inputCulture, outputCulture);
}
public static Result CreateResult(decimal? roundedResult, string iconPath, CultureInfo culture)
public static Result CreateResult(decimal? roundedResult, string iconPath, CultureInfo inputCulture, CultureInfo outputCulture)
{
// Return null when the expression is not a valid calculator query.
if (roundedResult == null)
@@ -28,11 +28,12 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
return new Result
{
// Using CurrentCulture since this is user facing
Title = roundedResult?.ToString(culture),
Title = roundedResult?.ToString(outputCulture),
IcoPath = iconPath,
Score = 300,
SubTitle = Properties.Resources.wox_plugin_calculator_copy_number_to_clipboard,
Action = c => Action(roundedResult, culture),
Action = c => Action(roundedResult, outputCulture),
QueryTextDisplay = roundedResult?.ToString(inputCulture),
};
}