From 13fd1ebb4ffcbc2ab28b885a18a6d363954c6940 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 18:03:46 +0200 Subject: [PATCH] feat: added whitespaces removing from environment values One user somehow got it in game running command. Have no idea how could it happend but just in case added `trim()` calls --- src/ui/preferences/environment.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ui/preferences/environment.rs b/src/ui/preferences/environment.rs index 19d168d..e94d7bd 100644 --- a/src/ui/preferences/environment.rs +++ b/src/ui/preferences/environment.rs @@ -91,11 +91,11 @@ impl SimpleAsyncComponent for EnvironmentApp { adw::EntryRow { set_title: "%command%", - set_text: CONFIG.game.command.as_ref().unwrap_or(&String::new()), + set_text: CONFIG.game.command.as_ref().unwrap_or(&String::new()).trim(), connect_changed => |entry| { if let Ok(mut config) = config::get() { - let command = entry.text().to_string(); + let command = entry.text().trim().to_string(); config.game.command = if command.is_empty() { None @@ -158,7 +158,7 @@ impl SimpleAsyncComponent for EnvironmentApp { }; for (name, value) in &CONFIG.game.environment { - model.variables.guard().push_back((name.clone(), value.clone())); + model.variables.guard().push_back((name.trim().to_string(), value.trim().to_string())); } let variables = model.variables.widget(); @@ -175,8 +175,8 @@ impl SimpleAsyncComponent for EnvironmentApp { match msg { EnvironmentMsg::Add => { if let Ok(mut config) = config::get() { - let name = self.name.text().to_string(); - let value = self.value.text().to_string(); + let name = self.name.text().trim().to_string(); + let value = self.value.text().trim().to_string(); config.game.environment.insert(name.clone(), value.clone());