From 103d3832a087a6a9d7bc341898d9291367fdd158 Mon Sep 17 00:00:00 2001 From: dcog989 Date: Fri, 12 Sep 2025 19:30:07 +0100 Subject: [PATCH] dead code, improve messages, group separator fix? --- .../Flow.Launcher.Plugin.Calculator/Main.cs | 18 +++++++++++------- .../MainRegexHelper.cs | 3 --- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs index d2e1ed821..85cd8a6fd 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs @@ -115,16 +115,15 @@ namespace Flow.Launcher.Plugin.Calculator }; } } - catch (Exception e) + catch (Exception) { + // Mages engine can throw various exceptions, for simplicity we catch them all and show a generic message. return new List { new Result { - Title = e.Message, - SubTitle = "Calculator Exception", - IcoPath = "Images/calculator.png", - Score = 300 + Title = Localize.flowlauncher_plugin_calculator_expression_not_complete(), + IcoPath = "Images/calculator.png" } }; } @@ -201,14 +200,19 @@ namespace Flow.Launcher.Plugin.Calculator private string GetGroupSeparator(string decimalSeparator) { + if (_settings.DecimalSeparator == DecimalSeparator.UseSystemLocale) + { + return CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator; + } + // This logic is now independent of the system's group separator - // to ensure consistent output for unit testing. + // to ensure consistent output when a specific separator is chosen. return decimalSeparator == Dot ? Comma : Dot; } private bool CanCalculate(Query query) { - if (query.Search.Length < 2) + if (string.IsNullOrWhiteSpace(query.Search)) { return false; } diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/MainRegexHelper.cs b/Plugins/Flow.Launcher.Plugin.Calculator/MainRegexHelper.cs index 85db0c2cd..2e0353614 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/MainRegexHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.Calculator/MainRegexHelper.cs @@ -8,9 +8,6 @@ internal static partial class MainRegexHelper [GeneratedRegex(@"[\(\)\[\]]", RegexOptions.Compiled)] public static partial Regex GetRegBrackets(); - [GeneratedRegex(@"^(ceil|floor|exp|pi|e|max|min|det|abs|log|ln|sqrt|sin|cos|tan|arcsin|arccos|arctan|eigval|eigvec|eig|sum|polar|plot|round|sort|real|zeta|bin2dec|hex2dec|oct2dec|factorial|sign|isprime|isinfty|==|~=|&&|\|\||(?:\<|\>)=?|[ei]|[0-9]|0x[\da-fA-F]+|[\+\%\-\*\/\^\., ""]|[\(\)\|\!\[\]])+$", RegexOptions.Compiled)] - public static partial Regex GetRegValidExpressChar(); - [GeneratedRegex(@"-?[\d\.,]+", RegexOptions.Compiled)] public static partial Regex GetNumberRegex();