From 575900024dbbf60073e5fcc1c548eb2f82cd22c1 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 10 Oct 2024 22:31:04 -0600 Subject: [PATCH] Avoid resetting diff state on unit config reload --- objdiff-gui/src/app.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/objdiff-gui/src/app.rs b/objdiff-gui/src/app.rs index 899fc51..b79d1c6 100644 --- a/objdiff-gui/src/app.rs +++ b/objdiff-gui/src/app.rs @@ -267,15 +267,25 @@ impl AppState { } pub fn set_selected_obj(&mut self, config: ObjectConfig) { - if self.config.selected_obj.as_ref().is_some_and(|existing| existing == &config) { - // Don't reload the object if there were no changes - return; + let mut unit_changed = true; + if let Some(existing) = self.config.selected_obj.as_ref() { + if existing == &config { + // Don't reload the object if there were no changes + return; + } + if existing.name == config.name { + unit_changed = false; + } } self.config.selected_obj = Some(config); - self.obj_change = true; - self.queue_build = false; - self.selecting_left = None; - self.selecting_right = None; + if unit_changed { + self.obj_change = true; + self.queue_build = false; + self.selecting_left = None; + self.selecting_right = None; + } else { + self.queue_build = true; + } } pub fn clear_selected_obj(&mut self) {