Skip to content

Commit 8282ad8

Browse files
authored
Merge pull request #370 from Flow-Launcher/calculator_e
add e to calculator plugin, and fix a NPE for debugging
2 parents 2f161b6 + 66eaa0a commit 8282ad8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ public class Main : IPlugin, IPluginI18n, ISavable, ISettingProvider
3232

3333
static Main()
3434
{
35-
MagesEngine = new Engine();
35+
MagesEngine = new Engine(new Configuration
36+
{
37+
Scope = new Dictionary<string, object>
38+
{
39+
{ "e", Math.E }, // e is not contained in the default mages engine
40+
}
41+
});
3642
}
3743

3844
public void Init(PluginInitContext context)
@@ -55,7 +61,7 @@ public List<Result> Query(Query query)
5561
var expression = query.Search.Replace(",", ".");
5662
var result = MagesEngine.Interpret(expression);
5763

58-
if (result.ToString() == "NaN")
64+
if (result?.ToString() == "NaN")
5965
result = Context.API.GetTranslation("flowlauncher_plugin_calculator_not_a_number");
6066

6167
if (result is Function)

Plugins/Flow.Launcher.Plugin.Calculator/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "Calculator",
55
"Description": "Provide mathematical calculations.(Try 5*3-2 in Flow Launcher)",
66
"Author": "cxfksword",
7-
"Version": "1.1.4",
7+
"Version": "1.1.5",
88
"Language": "csharp",
99
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1010
"ExecuteFileName": "Flow.Launcher.Plugin.Caculator.dll",

0 commit comments

Comments
 (0)