MCPcopy Index your code
hub / github.com/encounter/objdiff / save_config

Method save_config

objdiff-gui/src/app.rs:410–439  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

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();

Callers 4

set_selecting_leftMethod · 0.80
set_selecting_rightMethod · 0.80
set_symbol_mappingMethod · 0.80
clear_mappingsMethod · 0.80

Calls 3

save_project_configFunction · 0.85
iter_mutMethod · 0.80
show_error_toastMethod · 0.80

Tested by

no test coverage detected