From 2868da607002efbe9d23746c135f5157e10339b8 Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Thu, 9 Nov 2023 16:11:00 +0100 Subject: [PATCH] node text input: don't remove `.` for internal commands --- .../gui/elements/input/node/NodeTextInputElement.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/elements/input/node/NodeTextInputElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/elements/input/node/NodeTextInputElement.kt index f7c25bf7b..25d0ca5aa 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/elements/input/node/NodeTextInputElement.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/elements/input/node/NodeTextInputElement.kt @@ -121,11 +121,13 @@ class NodeTextInputElement( } fun updateSuggestion(suggestion: Suggestion) { - val slash = value.startsWith("/") - var value = SuggestionUtil.apply(value.removePrefix("/"), suggestion) - if (slash) { - value = "/$value" // TODO: dirty hack + val prefix = when { // TODO: really dirty dirty hack to not remove the / or . before the command. ChatNode should be responsible for that + value.startsWith("/") -> "/" + value.startsWith(".") -> "." + else -> "" } + var value = SuggestionUtil.apply(value.removePrefix(prefix), suggestion) + value = prefix + value _set(value) forceApply() }