Summary: | Don't require equals sign before common math operations like sqrt() and log() | ||
---|---|---|---|
Product: | [Plasma] krunner | Reporter: | David <david.cortes.rivera> |
Component: | general | Assignee: | Alexander Lohnau <alexander.lohnau> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | alexander.lohnau, natalie_clarius, nate |
Priority: | NOR | Keywords: | usability |
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/plasma/plasma-workspace/commit/4cddacf865585995e8b9421becf2a92cd515b9b3 | Version Fixed In: | 6.0 |
Sentry Crash Report: |
Description
David
2023-03-15 20:05:12 UTC
It does understand it if you put a "=" in front. Though I agree it's a little strange that it needs that for some operations but not others. > In contrast, it understands 2^0.5
So then, it *does* know how to do basic math functions like square root, no? ;)
We can certainly improve the syntax though, as Natalie alludes to.
I did some digging libqualculate has API to check if a string (lets say "sqrt") is a known function name. If we do some parsing beforehand, we could check if the parsed function name is known to qalculate. If yes, we do not require the "=" in front. A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2812 Git commit 4cddacf865585995e8b9421becf2a92cd515b9b3 by Alexander Lohnau. Committed on 28/04/2023 at 16:58. Pushed by alex into branch 'master'. runners/calculator: Do not require "=" prefix for known functions This utilized the qalculate API to get a function by its name. In case the function is not known, we get a nullptr and return false in our helper function. To avoid unintended results, the syntax of "functionname(<argument>)" is enforced using a regex. M +19 -0 runners/calculator/autotests/calculatorrunnertest.cpp M +14 -0 runners/calculator/calculatorrunner.cpp M +5 -0 runners/calculator/qalculate_engine.cpp M +3 -0 runners/calculator/qalculate_engine.h https://invent.kde.org/plasma/plasma-workspace/commit/4cddacf865585995e8b9421becf2a92cd515b9b3 |