mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
review feedback, CultureInvariant, mild refactor
This commit is contained in:
parent
edc76faeb4
commit
9be8b71f09
2 changed files with 5 additions and 15 deletions
|
|
@ -212,17 +212,8 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
var parts = processedStr.Split('.');
|
||||
if (parts.Length > 1)
|
||||
{
|
||||
bool isGrouped = true;
|
||||
for (var i = 1; i < parts.Length; i++)
|
||||
{
|
||||
if (parts[i].Length != 3)
|
||||
{
|
||||
isGrouped = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isGrouped)
|
||||
var culture = CultureInfo.CurrentCulture;
|
||||
if (IsValidGrouping(parts, culture.NumberFormat.NumberGroupSizes))
|
||||
{
|
||||
processedStr = processedStr.Replace(groupSep, "");
|
||||
}
|
||||
|
|
@ -300,7 +291,6 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
private string FormatResult(decimal roundedResult)
|
||||
{
|
||||
string decimalSeparator = GetDecimalSeparator();
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ namespace Flow.Launcher.Plugin.Calculator;
|
|||
|
||||
internal static partial class MainRegexHelper
|
||||
{
|
||||
[GeneratedRegex(@"-?[\d\.,]+", RegexOptions.Compiled)]
|
||||
[GeneratedRegex(@"-?[\d\.,'\u00A0\u202F]+", RegexOptions.Compiled | RegexOptions.CultureInvariant)]
|
||||
public static partial Regex GetNumberRegex();
|
||||
|
||||
[GeneratedRegex(@"\B(?=(\d{3})+(?!\d))", RegexOptions.Compiled)]
|
||||
public static partial Regex GetThousandGroupRegex();
|
||||
|
||||
[GeneratedRegex(@"\bpow(\((?:[^()\[\]]|\((?<Depth>)|\)(?<-Depth>)|\[(?<Depth>)|\](?<-Depth>))*(?(Depth)(?!))\))", RegexOptions.Compiled | RegexOptions.RightToLeft | RegexOptions.IgnoreCase)]
|
||||
[GeneratedRegex(@"\bpow(\((?:[^()\[\]]|\((?<Depth>)|\)(?<-Depth>)|\[(?<Depth>)|\](?<-Depth>))*(?(Depth)(?!))\))", RegexOptions.Compiled | RegexOptions.RightToLeft | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
|
||||
public static partial Regex GetPowRegex();
|
||||
|
||||
[GeneratedRegex(@"\b(sqrt|pow|factorial|abs|sign|ceil|floor|round|exp|log|log2|log10|min|max|lt|eq|gt|sin|cos|tan|arcsin|arccos|arctan|isnan|isint|isprime|isinfty|rand|randi|type|is|as|length|throw|catch|eval|map|clamp|lerp|regex|shuffle)\s*\(", RegexOptions.Compiled | RegexOptions.IgnoreCase)]
|
||||
[GeneratedRegex(@"\b(sqrt|pow|factorial|abs|sign|ceil|floor|round|exp|log|log2|log10|min|max|lt|eq|gt|sin|cos|tan|arcsin|arccos|arctan|isnan|isint|isprime|isinfty|rand|randi|type|is|as|length|throw|catch|eval|map|clamp|lerp|regex|shuffle)\s*\(", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
|
||||
public static partial Regex GetFunctionRegex();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue