dead code, improve messages, group separator fix?

This commit is contained in:
dcog989 2025-09-12 19:30:07 +01:00
parent e1079396c3
commit 103d3832a0
2 changed files with 11 additions and 10 deletions

View file

@ -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<Result>
{
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;
}

View file

@ -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();