Skip to content

Commit cef09b3

Browse files
taoocerospavelzw
andcommitted
add e to calculator plugin, and fix a NPE for debugging
Co-Authored-By: Pavel Zwerschke <[email protected]>
1 parent 890f114 commit cef09b3

File tree

1 file changed

+8
-2
lines changed
  • Plugins/Flow.Launcher.Plugin.Calculator

1 file changed

+8
-2
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)

0 commit comments

Comments
 (0)