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 1/2] 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 5b23ceacc30..ab8ce892a7f 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs @@ -32,7 +32,13 @@ public class Main : IPlugin, IPluginI18n, ISavable, ISettingProvider 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 @@ public List Query(Query query) 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) From 66eaa0a2cd207398a8cda1332920789e073c1f4e 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 18:12:00 +0800 Subject: [PATCH 2/2] version bump --- Plugins/Flow.Launcher.Plugin.Calculator/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json b/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json index 7d9ca58d58f..9bf532e8791 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json @@ -4,7 +4,7 @@ "Name": "Calculator", "Description": "Provide mathematical calculations.(Try 5*3-2 in Flow Launcher)", "Author": "cxfksword", - "Version": "1.1.4", + "Version": "1.1.5", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Caculator.dll",