From 76f834ff1b88fe09c2025cef55b7aa968e85f424 Mon Sep 17 00:00:00 2001 From: dcog989 Date: Wed, 23 Jul 2025 17:56:58 +0100 Subject: [PATCH] PR review changes --- Plugins/Flow.Launcher.Plugin.Calculator/Main.cs | 15 +++++++++++---- .../Flow.Launcher.Plugin.Calculator/plugin.json | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs index afd0ddfe5..e9ea2d08c 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs @@ -219,11 +219,10 @@ namespace Flow.Launcher.Plugin.Calculator return numberStr; } - private string FormatResult(decimal roundedResult, ParsingContext context) { string decimalSeparator = context.InputDecimalSeparator ?? GetDecimalSeparator(); - string groupSeparator = decimalSeparator == dot ? comma : dot; + string groupSeparator = GetGroupSeparator(decimalSeparator); string resultStr = roundedResult.ToString(CultureInfo.InvariantCulture); @@ -231,7 +230,7 @@ namespace Flow.Launcher.Plugin.Calculator string integerPart = parts[0]; string fractionalPart = parts.Length > 1 ? parts[1] : string.Empty; - if (context.InputUsesGroupSeparators) + if (context.InputUsesGroupSeparators && integerPart.Length > 3) { integerPart = ThousandGroupRegex.Replace(integerPart, groupSeparator); } @@ -244,9 +243,17 @@ namespace Flow.Launcher.Plugin.Calculator return integerPart; } + private string GetGroupSeparator(string decimalSeparator) + { + // Use system culture's group separator when available and it doesn't conflict + var systemGroupSep = CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator; + return decimalSeparator == systemGroupSep + ? (decimalSeparator == dot ? comma : dot) + : systemGroupSep; + } + private bool CanCalculate(Query query) { - // Don't execute when user only input "e" or "i" keyword if (query.Search.Length < 2) { return false; diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json b/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json index 739572930..c9435e043 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json @@ -4,7 +4,7 @@ "Name": "Calculator", "Description": "Perform mathematical calculations (including hexadecimal values). Use ',' or '.' as thousand separator or decimal place.", "Author": "cxfksword, dcog989", - "Version": "1.1.0", + "Version": "1.0.0", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Calculator.dll",