calc() handeling of unitless numbers breaks decimals and causes rounding errors with fractions #1801
-
I hope that I understood the request in If you have issues with themes in 1.7.0 please read this! · Issue #1397 · davatorium/rofi properly (that I should issues here rather than in the issues). SituationI was trying to use Throughout the rest of my theme, I wrote the the padding in em with decimals (em because it is adaptive to the interface size (not just the screen size) and decimals because it is the only convenient way to set fractional values (as actual fractions require a Overview of Expected Behavior According to DocumentationThe documentation about the From what was there (a list of standard operations like
As far as I know, the rofi-theme manpage established a few key things about distance units that are relevant.
What Actually Happens
While these behaviors are consistent with the rest of the program, they certainly aren't what many would expect from a (This was not helped by the error messages as apparently these error can cause parsing errors resulting in messages suggesting I was missing parentheses and or that I was somehow getting the syntax wrong for using the basic operations . I spent time messing with spacing and replacing negative numbers with subtractions from 0 (lol).) A Few Examples of 'Weird' Things(Yes, all of these are not 'weird' in that they are inconsistent with the rest of the system, but they are weird because they aren't what many would expect from a 1/2 of 500 = 0
em/em = px /* Equal */
y-offset: calc(-250em/1em);
y-offset: calc(-250); Fractions work; Decimals don'tThis includes the way I would have expected to solve my problem on the bottom and the way I found that works on the top. /* Works as expected */
y-offset: calc(-16em/2 * 3/2);
y-offset: calc(-1.5em*16/2);
/* Breaks with `syntax error, unexpected "Parent right (')')"` */
y-offset: calc(-16em/2 * 1.5); This is the only thing that really feels 'broken.' I would expect to be able to use any type of number when using 'unit-less' numbers in my calculation, and then have the results rounded to fit whatever unit they're in. The current system, however, limits those numbers (used to represent lines or scaling factors) as if they were pixels which is limiting, and because of the lack of documentation/misleading error message, somewhat confusing. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 17 replies
-
Thanks for the detailed description. |
Beta Was this translation helpful? Give feedback.
-
/* This still results in 0 offset */
y-offset: calc(1/2 * 500);
/* Still working */
y-offset: calc(-16em/2 * 3/2);
y-offset: calc(-1.5em*16/2);
/* Still breaks with `syntax error, unexpected "Parent right (')')"` */
y-offset: calc(-16em/2 * 1.5);
/* Tested afterward to make sure it wasn't just a floor divide thing with some other int number It also brakes when it is given as a decimal ( although the error about the unexpected thing element is the '*' operator itself) */
y-offset: calc(0.5 * 500px); The first test seems most decisive about weather it worked as it showed there is still intermediate rounding going on somewhere. It seems I'm in the right branch because
The commits are showing in Clearly something fishy going on here. I ran |
Beta Was this translation helpful? Give feedback.
-
After a little bit of multitasking here are the results: On the good side, I retested all the ones that did not work and they do work (which is really good because the source looked very thoroughly fixed to me). |
Beta Was this translation helpful? Give feedback.
-
The issue is resolved and the new behavior will be in the next release. |
Beta Was this translation helpful? Give feedback.
The issue is resolved and the new behavior will be in the next release.