From 514dec641a6a44f061cb322389230f5d389fbbba Mon Sep 17 00:00:00 2001 From: Alessevan <44125445+Alessevan@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:05:36 +0100 Subject: [PATCH] feat: better displayed matching percents --- objdiff-core/config-schema.json | 30 ++++++++++++++++++++++++++++ objdiff-gui/src/app_config.rs | 8 +++++++- objdiff-gui/src/views/symbol_diff.rs | 27 +++++++++++++++++++++---- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/objdiff-core/config-schema.json b/objdiff-core/config-schema.json index c6d43572..89bd9dbd 100644 --- a/objdiff-core/config-schema.json +++ b/objdiff-core/config-schema.json @@ -103,6 +103,34 @@ } ] }, + { + "id": "preferredMatchingPercentSeparator", + "type": "choice", + "default": "parenthesis", + "name": "Change matching percent seperator", + "description": "Change the separator between a symbol's name and its matching percent.", + "items": [ + { + "value": "parenthesis", + "name": "()" + }, + { + "value": "pipe", + "name": "|" + }, + { + "value": "dash", + "name": "-" + } + ] + }, + { + "id": "spacedMatchingPercent", + "type": "boolean", + "default": true, + "name": "Spaced Matching Percent", + "description": "Add spaces to align every matching percent on the right." + }, { "id": "combineDataSections", "type": "boolean", @@ -394,6 +422,8 @@ "functionRelocDiffs", "demangler", "showSymbolSizes", + "preferredMatchingPercentSeparator", + "spacedMatchingPercent", "spaceBetweenArgs", "combineDataSections", "combineTextSections" diff --git a/objdiff-gui/src/app_config.rs b/objdiff-gui/src/app_config.rs index 0bbde3be..9fdbeb2a 100644 --- a/objdiff-gui/src/app_config.rs +++ b/objdiff-gui/src/app_config.rs @@ -6,7 +6,7 @@ use objdiff_core::{ config::ScratchConfig, diff::{ ArmArchVersion, ArmR9Usage, DiffObjConfig, FunctionRelocDiffs, MipsAbi, MipsInstrCategory, - ShowSymbolSizes, X86Formatter, + PreferredMatchingPercentSeparator, ShowSymbolSizes, X86Formatter, }, }; use typed_path::{Utf8PlatformPathBuf, Utf8UnixPathBuf}; @@ -228,6 +228,8 @@ pub struct DiffObjConfigV1 { #[serde(default = "bool_true")] pub space_between_args: bool, pub show_symbol_sizes: ShowSymbolSizes, + pub preferred_matching_percent_separator: PreferredMatchingPercentSeparator, + pub spaced_matching_percent: bool, pub combine_data_sections: bool, // x86 pub x86_formatter: X86Formatter, @@ -250,6 +252,8 @@ impl Default for DiffObjConfigV1 { relax_reloc_diffs: false, space_between_args: true, show_symbol_sizes: Default::default(), + preferred_matching_percent_separator: Default::default(), + spaced_matching_percent: true, combine_data_sections: false, x86_formatter: Default::default(), mips_abi: Default::default(), @@ -275,6 +279,8 @@ impl DiffObjConfigV1 { }, space_between_args: self.space_between_args, show_symbol_sizes: self.show_symbol_sizes, + preferred_matching_percent_separator: self.preferred_matching_percent_separator, + spaced_matching_percent: self.spaced_matching_percent, combine_data_sections: self.combine_data_sections, x86_formatter: self.x86_formatter, mips_abi: self.mips_abi, diff --git a/objdiff-gui/src/views/symbol_diff.rs b/objdiff-gui/src/views/symbol_diff.rs index f3da58e5..a2c98391 100644 --- a/objdiff-gui/src/views/symbol_diff.rs +++ b/objdiff-gui/src/views/symbol_diff.rs @@ -7,7 +7,7 @@ use egui::{ use egui_extras::{Column, TableBuilder}; use objdiff_core::{ diff::{ - DiffObjConfig, ObjectDiff, ShowSymbolSizes, SymbolDiff, + DiffObjConfig, ObjectDiff, PreferredMatchingPercentSeparator, ShowSymbolSizes, SymbolDiff, display::{ HighlightKind, SectionDisplay, SymbolFilter, SymbolNavigationKind, display_sections, symbol_context, symbol_hover, @@ -722,14 +722,33 @@ fn symbol_ui( write_text("] ", appearance.text_color, &mut job, appearance.code_font.clone()); } if let Some(match_percent) = symbol_diff.match_percent { - write_text("(", appearance.text_color, &mut job, appearance.code_font.clone()); + if diff_config.preferred_matching_percent_separator + == PreferredMatchingPercentSeparator::Parenthesis + { + write_text("(", appearance.text_color, &mut job, appearance.code_font.clone()); + } + let formatted_percent = if diff_config.spaced_matching_percent { + &format!("{:3.0}%", match_percent.floor()) + } else { + &format!("{:.0}%", match_percent.floor()) + }; write_text( - &format!("{:.0}%", match_percent.floor()), + formatted_percent, match_color_for_symbol(match_percent, appearance), &mut job, appearance.code_font.clone(), ); - write_text(") ", appearance.text_color, &mut job, appearance.code_font.clone()); + let seperator = match diff_config.preferred_matching_percent_separator { + PreferredMatchingPercentSeparator::Parenthesis => ")", + PreferredMatchingPercentSeparator::Dash => " -", + PreferredMatchingPercentSeparator::Pipe => " |", + }; + write_text( + &format!("{} ", seperator), + appearance.text_color, + &mut job, + appearance.code_font.clone(), + ); } write_text(name, appearance.highlight_color, &mut job, appearance.code_font.clone()); if diff_config.show_symbol_sizes == ShowSymbolSizes::Decimal {