mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add e to calculator plugin, and fix a NPE for debugging
Co-Authored-By: Pavel Zwerschke <pavelzw@gmail.com>
This commit is contained in:
parent
890f114931
commit
cef09b3ee2
1 changed files with 8 additions and 2 deletions
|
|
@ -32,7 +32,13 @@ namespace Flow.Launcher.Plugin.Caculator
|
||||||
|
|
||||||
static Main()
|
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)
|
public void Init(PluginInitContext context)
|
||||||
|
|
@ -55,7 +61,7 @@ namespace Flow.Launcher.Plugin.Caculator
|
||||||
var expression = query.Search.Replace(",", ".");
|
var expression = query.Search.Replace(",", ".");
|
||||||
var result = MagesEngine.Interpret(expression);
|
var result = MagesEngine.Interpret(expression);
|
||||||
|
|
||||||
if (result.ToString() == "NaN")
|
if (result?.ToString() == "NaN")
|
||||||
result = Context.API.GetTranslation("flowlauncher_plugin_calculator_not_a_number");
|
result = Context.API.GetTranslation("flowlauncher_plugin_calculator_not_a_number");
|
||||||
|
|
||||||
if (result is Function)
|
if (result is Function)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue