Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ public class Main : IPlugin, IPluginI18n, ISavable, ISettingProvider

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)
Expand All @@ -55,7 +61,7 @@ public List<Result> 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)
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Calculator/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down