(&mut self)
| 408 | } |
| 409 | |
| 410 | pub fn save_config(&mut self) { |
| 411 | let (Some(config), Some(info)) = |
| 412 | (self.current_project_config.as_mut(), self.project_config_info.as_mut()) |
| 413 | else { |
| 414 | return; |
| 415 | }; |
| 416 | // Update the project config with the current state |
| 417 | if let Some(object) = self.config.selected_obj.as_ref() { |
| 418 | if let Some(existing) = config.units.as_mut().and_then(|v| { |
| 419 | v.iter_mut().find(|u| u.name.as_ref().is_some_and(|n| n == &object.name)) |
| 420 | }) { |
| 421 | existing.symbol_mappings = if object.symbol_mappings.is_empty() { |
| 422 | None |
| 423 | } else { |
| 424 | Some(object.symbol_mappings.clone()) |
| 425 | }; |
| 426 | } |
| 427 | if let Some(existing) = self.objects.iter_mut().find(|u| u.name == object.name) { |
| 428 | existing.symbol_mappings = object.symbol_mappings.clone(); |
| 429 | } |
| 430 | } |
| 431 | // Save the updated project config |
| 432 | match save_project_config(config, info) { |
| 433 | Ok(new_info) => *info = new_info, |
| 434 | Err(e) => { |
| 435 | log::error!("Failed to save project config: {e:#}"); |
| 436 | self.show_error_toast("Failed to save project config", &e); |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | pub fn show_error_toast(&mut self, context: &str, e: &anyhow::Error) { |
| 442 | let mut job = LayoutJob::default(); |
no test coverage detected