From cef09b3ee29df2310d409307224e7c4231aeddca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Fri, 26 Feb 2021 16:20:47 +0800 Subject: [PATCH] add e to calculator plugin, and fix a NPE for debugging Co-Authored-By: Pavel Zwerschke --- Plugins/Flow.Launcher.Plugin.Calculator/Main.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs index 5b23ceacc..ab8ce892a 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs @@ -32,7 +32,13 @@ namespace Flow.Launcher.Plugin.Caculator static Main() { - MagesEngine = new Engine(); + MagesEngine = new Engine(new Configuration + { + Scope = new Dictionary + { + { "e", Math.E }, // e is not contained in the default mages engine + } + }); } public void Init(PluginInitContext context) @@ -55,7 +61,7 @@ namespace Flow.Launcher.Plugin.Caculator var expression = query.Search.Replace(",", "."); var result = MagesEngine.Interpret(expression); - if (result.ToString() == "NaN") + if (result?.ToString() == "NaN") result = Context.API.GetTranslation("flowlauncher_plugin_calculator_not_a_number"); if (result is Function)