From dd2c01b461f0b86b565ebae37a3c50aaede750ee Mon Sep 17 00:00:00 2001 From: Username404 Date: Thu, 24 Jun 2021 22:19:15 +0200 Subject: [PATCH] Don't make a local variable when adding a Macro in ConfigScreen.kt --- .../kotlin/fr/username404/snowygui/config/ConfigScreen.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt index cc02761..06bf72a 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt @@ -88,10 +88,8 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) { ) } }.setTooltip(TranslatableComponent("$confPrefix.general.macros.tooltip")).setSaveConsumer { it.forEach { string -> - val splitString: Pair? = string.split(":").map { toTrim -> toTrim.trimStart() }.let { element -> - if (element.size == 2) element.component1() to element.component2() else null - }; if (splitString != null) { - Macro(title = splitString.first, command = splitString.second).let { newMacro -> + with(string.split(":")) { + if (size == 2) Macro(title = component1().trimStart(), command = component2().trim()).let { newMacro -> macrosButtons.removeIf { existingMacro -> (existingMacro.title == newMacro.title) || (existingMacro.command == newMacro.command)