PR review changes

This commit is contained in:
dcog989 2025-07-23 17:56:58 +01:00
parent 161c5462ba
commit 76f834ff1b
2 changed files with 12 additions and 5 deletions

View file

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

View file

@ -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",