[PTRun][Calc]Add list separator handling for different cultures (#36735)

This commit is contained in:
PesBandi
2025-02-21 09:26:52 +01:00
committed by GitHub
parent 17f3c12a11
commit 273a45ff1f
2 changed files with 2 additions and 1 deletions

View File

@@ -74,6 +74,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
[DataRow("5,2+6", "5.2+6")] [DataRow("5,2+6", "5.2+6")]
[DataRow("round(2,5)", "round(2.5)")] [DataRow("round(2,5)", "round(2.5)")]
[DataRow("3,3333", "3.3333")] [DataRow("3,3333", "3.3333")]
[DataRow("max(2;3)", "max(2,3)")]
public void Translate_NoErrors_WhenCalled(string input, string expectedResult) public void Translate_NoErrors_WhenCalled(string input, string expectedResult)
{ {
// Arrange // Arrange

View File

@@ -123,7 +123,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
outputBuilder.Append( outputBuilder.Append(
decimal.TryParse(token, NumberStyles.Number, cultureFrom, out number) decimal.TryParse(token, NumberStyles.Number, cultureFrom, out number)
? (new string('0', leadingZeroCount) + number.ToString(cultureTo)) ? (new string('0', leadingZeroCount) + number.ToString(cultureTo))
: token); : token.Replace(cultureFrom.TextInfo.ListSeparator, cultureTo.TextInfo.ListSeparator));
} }
} }