From 603dbd6882650b82e0991b54607e47de298a4175 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 7 Oct 2024 20:17:56 -0600 Subject: [PATCH] Round match percent down before display Ensures that 100% isn't displayed until it's a perfect match. --- objdiff-gui/src/views/extab_diff.rs | 2 +- objdiff-gui/src/views/function_diff.rs | 2 +- objdiff-gui/src/views/symbol_diff.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/objdiff-gui/src/views/extab_diff.rs b/objdiff-gui/src/views/extab_diff.rs index 299f5a4..8372b3e 100644 --- a/objdiff-gui/src/views/extab_diff.rs +++ b/objdiff-gui/src/views/extab_diff.rs @@ -172,7 +172,7 @@ pub fn extab_diff_ui(ui: &mut egui::Ui, state: &mut DiffViewState, appearance: & { ui.colored_label( match_color_for_symbol(match_percent, appearance), - format!("{match_percent:.0}%"), + format!("{:.0}%", match_percent.floor()), ); } else { ui.colored_label(appearance.replace_color, "Missing"); diff --git a/objdiff-gui/src/views/function_diff.rs b/objdiff-gui/src/views/function_diff.rs index 07c430d..65cfd2c 100644 --- a/objdiff-gui/src/views/function_diff.rs +++ b/objdiff-gui/src/views/function_diff.rs @@ -546,7 +546,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, state: &mut DiffViewState, appearance { ui.colored_label( match_color_for_symbol(match_percent, appearance), - format!("{match_percent:.0}%"), + format!("{:.0}%", match_percent.floor()), ); } else { ui.colored_label(appearance.replace_color, "Missing"); diff --git a/objdiff-gui/src/views/symbol_diff.rs b/objdiff-gui/src/views/symbol_diff.rs index 3e19b58..8d9618c 100644 --- a/objdiff-gui/src/views/symbol_diff.rs +++ b/objdiff-gui/src/views/symbol_diff.rs @@ -284,7 +284,7 @@ fn symbol_ui( if let Some(match_percent) = symbol_diff.match_percent { write_text("(", appearance.text_color, &mut job, appearance.code_font.clone()); write_text( - &format!("{match_percent:.0}%"), + &format!("{:.0}%", match_percent.floor()), match_color_for_symbol(match_percent, appearance), &mut job, appearance.code_font.clone(), @@ -389,7 +389,7 @@ fn symbol_list_ui( appearance.code_font.clone(), ); write_text( - &format!("{match_percent:.0}%"), + &format!("{:.0}%", match_percent.floor()), match_color_for_symbol(match_percent, appearance), &mut header, appearance.code_font.clone(),