Comments (6)
Looks like we replace the "x" with "*":
https://github.com/elementary/applications-menu/blob/master/src/synapse-plugins/calculator-plugin/calculator-plugin-backend.vala#L60
Afterwards "ne*t" matches the following regexp:
https://github.com/elementary/applications-menu/blob/master/src/synapse-plugins/calculator-plugin/calculator-plugin-backend.vala#L44
Example: https://regex101.com/r/URh3rG
from applications-menu.
For reference, current reg exp: ^.*(\w+[\/\+\-\*\^\%\!\&\|]{1,2}\.?\w+|\(-?\d+.*\))+.*$
.
What if we go with something like: ^([-\d.]+[\/\+\-\*\^\%\!\&\|]{1,2}[-\d.]+)+$
- Uses more specific
\d
instead of\w
. Also supporting "-" and ".". - Removed
.*
at start and end, because it's not clear for me why they are there? - Removed the
\.?
before the\w+
. Why only allow an optional . before the \w here? - Removed
|\(-?\d+.*\)
because it's not in line with the description of ""
Example: https://regex101.com/r/aSz5MI
Would be really great to have some unit tests on this part, because I'm probably forgetting about many usecases.
Update: I should try this with the existing unit tests.
Update 2: My reg exp fails 50% of the calculator tests 😅
from applications-menu.
Looking for "Firefox beta" also returns the 0.
from applications-menu.
Looks like the "x" is interpreted as "multiply" even though the other parts are non-numeric and presumably parse to "0". Should be easy enough to check the non-operator parts are actually numbers?
from applications-menu.
Firefo^ Beta = 1 (interpreted as 0 ^ 0).
from applications-menu.
As bc
can handle multiple expressions it is possible for next
to be a valid expression: e.g. ne=3;t=4;next
gives the expected result 12
. The code in this app is too simplistic to handle this kind of thing. It just passes a string that might be a valid mathematical expression(s) to bc
and returns the result if bc
gives no error. Unfortunately bc
does not give an error for undefined variables - just assigns them the value 0
. Whether it is worth us trying to check for undefined variables here is questionable. It would be simpler to disallow variables altogether.
from applications-menu.
Related Issues (20)
- Improve handling of "ghost" pressing super key in open menu
- Include timestamp with app launch contexts
- SI units are not translatable
- unvisible apps (feature request) HOT 1
- Viber dont launch HOT 1
- Port to GTK4
- Labels don't change color after switching system style HOT 1
- Applications menu is too narrow HOT 9
- Ask support for full screen style HOT 3
- [Crash]Wingpanel is crashed if `<Alt><number>` pressed in GridView where `<number>` exceeds number of pages
- Aplication category not working for Education
- Blur apps that are behind the apps menu HOT 1
- Update settings plugin for Switchboard-3
- Changing icons doesn't appply any more to Applications-Menu HOT 1
- Focused item does not change after changing pages using `<Shift><Arrow>` or `<PgUp>`/`<PgDn>` or `Home`
- Use Gala interface for launch/focus HOT 3
- the menu of applications opens automaticly when im working on
- "Add to Dock" and "Remove from Dock" menu item with the our new dock HOT 2
- Missing application menu icons for snap apps
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from applications-menu.