mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
PR review changes
This commit is contained in:
parent
161c5462ba
commit
76f834ff1b
2 changed files with 12 additions and 5 deletions
|
|
@ -219,11 +219,10 @@ namespace Flow.Launcher.Plugin.Calculator
|
||||||
return numberStr;
|
return numberStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private string FormatResult(decimal roundedResult, ParsingContext context)
|
private string FormatResult(decimal roundedResult, ParsingContext context)
|
||||||
{
|
{
|
||||||
string decimalSeparator = context.InputDecimalSeparator ?? GetDecimalSeparator();
|
string decimalSeparator = context.InputDecimalSeparator ?? GetDecimalSeparator();
|
||||||
string groupSeparator = decimalSeparator == dot ? comma : dot;
|
string groupSeparator = GetGroupSeparator(decimalSeparator);
|
||||||
|
|
||||||
string resultStr = roundedResult.ToString(CultureInfo.InvariantCulture);
|
string resultStr = roundedResult.ToString(CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
|
@ -231,7 +230,7 @@ namespace Flow.Launcher.Plugin.Calculator
|
||||||
string integerPart = parts[0];
|
string integerPart = parts[0];
|
||||||
string fractionalPart = parts.Length > 1 ? parts[1] : string.Empty;
|
string fractionalPart = parts.Length > 1 ? parts[1] : string.Empty;
|
||||||
|
|
||||||
if (context.InputUsesGroupSeparators)
|
if (context.InputUsesGroupSeparators && integerPart.Length > 3)
|
||||||
{
|
{
|
||||||
integerPart = ThousandGroupRegex.Replace(integerPart, groupSeparator);
|
integerPart = ThousandGroupRegex.Replace(integerPart, groupSeparator);
|
||||||
}
|
}
|
||||||
|
|
@ -244,9 +243,17 @@ namespace Flow.Launcher.Plugin.Calculator
|
||||||
return integerPart;
|
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)
|
private bool CanCalculate(Query query)
|
||||||
{
|
{
|
||||||
// Don't execute when user only input "e" or "i" keyword
|
|
||||||
if (query.Search.Length < 2)
|
if (query.Search.Length < 2)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"Name": "Calculator",
|
"Name": "Calculator",
|
||||||
"Description": "Perform mathematical calculations (including hexadecimal values). Use ',' or '.' as thousand separator or decimal place.",
|
"Description": "Perform mathematical calculations (including hexadecimal values). Use ',' or '.' as thousand separator or decimal place.",
|
||||||
"Author": "cxfksword, dcog989",
|
"Author": "cxfksword, dcog989",
|
||||||
"Version": "1.1.0",
|
"Version": "1.0.0",
|
||||||
"Language": "csharp",
|
"Language": "csharp",
|
||||||
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
||||||
"ExecuteFileName": "Flow.Launcher.Plugin.Calculator.dll",
|
"ExecuteFileName": "Flow.Launcher.Plugin.Calculator.dll",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue