Skip to content

Commit 103d383

Browse files
committed
dead code, improve messages, group separator fix?
1 parent e107939 commit 103d383

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Plugins/Flow.Launcher.Plugin.Calculator/Main.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,15 @@ public List<Result> Query(Query query)
115115
};
116116
}
117117
}
118-
catch (Exception e)
118+
catch (Exception)
119119
{
120+
// Mages engine can throw various exceptions, for simplicity we catch them all and show a generic message.
120121
return new List<Result>
121122
{
122123
new Result
123124
{
124-
Title = e.Message,
125-
SubTitle = "Calculator Exception",
126-
IcoPath = "Images/calculator.png",
127-
Score = 300
125+
Title = Localize.flowlauncher_plugin_calculator_expression_not_complete(),
126+
IcoPath = "Images/calculator.png"
128127
}
129128
};
130129
}
@@ -201,14 +200,19 @@ private string FormatResult(decimal roundedResult)
201200

202201
private string GetGroupSeparator(string decimalSeparator)
203202
{
203+
if (_settings.DecimalSeparator == DecimalSeparator.UseSystemLocale)
204+
{
205+
return CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator;
206+
}
207+
204208
// This logic is now independent of the system's group separator
205-
// to ensure consistent output for unit testing.
209+
// to ensure consistent output when a specific separator is chosen.
206210
return decimalSeparator == Dot ? Comma : Dot;
207211
}
208212

209213
private bool CanCalculate(Query query)
210214
{
211-
if (query.Search.Length < 2)
215+
if (string.IsNullOrWhiteSpace(query.Search))
212216
{
213217
return false;
214218
}

Plugins/Flow.Launcher.Plugin.Calculator/MainRegexHelper.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ internal static partial class MainRegexHelper
88
[GeneratedRegex(@"[\(\)\[\]]", RegexOptions.Compiled)]
99
public static partial Regex GetRegBrackets();
1010

11-
[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)]
12-
public static partial Regex GetRegValidExpressChar();
13-
1411
[GeneratedRegex(@"-?[\d\.,]+", RegexOptions.Compiled)]
1512
public static partial Regex GetNumberRegex();
1613

0 commit comments

Comments
 (0)