mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
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:
commit
8282ad8aa8
2 changed files with 9 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue