Merge pull request #370 from Flow-Launcher/calculator_e

add e to calculator plugin, and fix a NPE for debugging
This commit is contained in:
Hongtao Zhang 2021-02-26 19:06:37 +08:00 committed by GitHub
commit 8282ad8aa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -32,7 +32,13 @@ namespace Flow.Launcher.Plugin.Caculator
static Main()
{
MagesEngine = new Engine();
MagesEngine = new Engine(new Configuration
{
Scope = new Dictionary<string, object>
{
{ "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)

View file

@ -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",