From 229741aaaed417396f89ab6a752bfa79bba44ce3 Mon Sep 17 00:00:00 2001 From: Laurent Garnier Date: Mon, 17 Jul 2023 16:50:02 +0200 Subject: [PATCH] [Sitemap UI] Do not break format defined in label with extra spaces Fix openhab/openhab-webui#1953 Fix a regression introduced by PR #3644 Signed-off-by: Laurent Garnier --- .../org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java index 1862082e2e8..8a96b4b9532 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java @@ -515,7 +515,8 @@ private QuantityType convertStateToWidgetUnit(QuantityType quantityState, "Item '{}' with unit, nothing allowed after unit in label pattern '{}', dropping postfix", itemName, pattern); } - pattern = pattern.substring(0, matcherEnd) + (!unit.isBlank() ? " " + unit : ""); + pattern = unit.isBlank() ? pattern.substring(0, matcherEnd) + : pattern.substring(0, pattern.indexOf(unit, matcherEnd) + unit.length()); } } catch (ItemNotFoundException e) { logger.warn("Cannot retrieve item '{}' for widget {}", itemName, w.eClass().getInstanceTypeName());