Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitemap editor: fix negative number parameters #3055

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

mherwege
Copy link
Contributor

@mherwege mherwege commented Feb 6, 2025

See: https://community.openhab.org/t/basic-ui-setpoint-negative-values/161011

Parameters with negative number where not parsed correctly. This is because hyphen is defined as a token and therefore already recognized before recognizing the number. Changing the order does not help as it breaks chart period parsing.

This fix avoids recognizing numbers as tokens and handles numbers in the lexer.

Tests where added and all existing tests still pass.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Copy link

relativeci bot commented Feb 6, 2025

#2784 Bundle Size — 10.98MiB (+0.01%).

49f3338(current) vs 95844d2 main#2743(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  no changes
                 Current
#2784
     Baseline
#2743
No change  Initial JS 1.9MiB 1.9MiB
No change  Initial CSS 577.21KiB 577.21KiB
No change  Cache Invalidation 17.51% 17.51%
No change  Chunks 227 227
No change  Assets 250 250
No change  Modules 2952 2952
No change  Duplicate Modules 154 154
No change  Duplicate Code 1.8% 1.8%
No change  Packages 98 98
No change  Duplicate Packages 2 2
Bundle size by type  Change 7 changes Regression 7 regressions
                 Current
#2784
     Baseline
#2743
Regression  JS 9.19MiB (+100%) undefined
Regression  CSS 867.33KiB (+100%) undefined
Regression  Fonts 526.1KiB (+100%) undefined
Regression  Media 295.6KiB (+100%) undefined
Regression  IMG 140.74KiB (+100%) undefined
Regression  HTML 1.38KiB (+100%) undefined
Regression  Other 871B (+100%) undefined

Bundle analysis reportBranch mherwege:sitemap_number_paramProject dashboard


Generated by RelativeCIDocumentationReport issue

@florian-h05 florian-h05 added bug Something isn't working main ui Main UI labels Feb 6, 2025
@jimtng
Copy link
Contributor

jimtng commented Feb 7, 2025

Would this work on browsers with a locale that uses a comma as the decimal point?

@mherwege
Copy link
Contributor Author

mherwege commented Feb 7, 2025

@jimtng

Would this work on browsers with a locale that uses a comma as the decimal point?

This is about the sitemap editor and how it parses sitemap xtext syntax, not about displayed values. So, this is not impacted by locale.
The parser first tokenizes and splits on tokens for efficiency. The nearly code was too aggressive at that. I took care to exactly match what is done in the core sitemap parser.

I assume you had our other discussion about input fields and uom in mind.

@jimtng
Copy link
Contributor

jimtng commented Feb 7, 2025

Oh good point, it just needs to be the same number syntax that core will use to parse the sitemap. I assume core will require a dot, regardless of its locale?

@mherwege
Copy link
Contributor Author

mherwege commented Feb 7, 2025

Oh good point, it just needs to be the same number syntax that core will use to parse the sitemap. I assume core will require a dot, regardless of its locale?

Yes, it does. the sitemap syntax does not depend on locale.

Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@florian-h05 florian-h05 added this to the 5.0 milestone Feb 15, 2025
@florian-h05 florian-h05 merged commit 6ce2d2e into openhab:main Feb 15, 2025
5 checks passed
@mherwege mherwege deleted the sitemap_number_param branch February 17, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants