@@ -94,6 +94,12 @@ pub enum DiffViewAction {
9494 FindSimilarFunctions { symbol_idx : usize , column : usize } ,
9595 /// Close the similar functions panel.
9696 CloseSimilarFunctions ,
97+ /// Set the similar functions search filter.
98+ SetSimilarSearch ( String ) ,
99+ /// Show/hide target-side results in the similar functions panel.
100+ SetSimilarShowTarget ( bool ) ,
101+ /// Show/hide base-side results in the similar functions panel.
102+ SetSimilarShowBase ( bool ) ,
97103}
98104
99105#[ derive( Debug , Clone , Default , Eq , PartialEq ) ]
@@ -125,6 +131,10 @@ pub struct SimilarFunctionsState {
125131 pub source_symbol_name : String ,
126132 /// `None` while the job is running; `Some` once complete
127133 pub matches : Option < Vec < SimilarFunctionMatch > > ,
134+ pub search : String ,
135+ pub search_regex : Option < Regex > ,
136+ pub show_target : bool ,
137+ pub show_base : bool ,
128138}
129139
130140#[ derive( Default ) ]
@@ -399,6 +409,26 @@ impl DiffViewState {
399409 DiffViewAction :: CloseSimilarFunctions => {
400410 self . similar_functions = None ;
401411 }
412+ DiffViewAction :: SetSimilarSearch ( search) => {
413+ if let Some ( state) = & mut self . similar_functions {
414+ state. search_regex = if search. is_empty ( ) {
415+ None
416+ } else {
417+ RegexBuilder :: new ( & search) . case_insensitive ( true ) . build ( ) . ok ( )
418+ } ;
419+ state. search = search;
420+ }
421+ }
422+ DiffViewAction :: SetSimilarShowTarget ( value) => {
423+ if let Some ( state) = & mut self . similar_functions {
424+ state. show_target = value;
425+ }
426+ }
427+ DiffViewAction :: SetSimilarShowBase ( value) => {
428+ if let Some ( state) = & mut self . similar_functions {
429+ state. show_base = value;
430+ }
431+ }
402432 DiffViewAction :: FindSimilarFunctions { symbol_idx, column } => {
403433 let Some ( result) = self . build . as_deref ( ) else { return } ;
404434 let Some ( ( source_obj, _) ) = ( match column {
@@ -413,8 +443,14 @@ impl DiffViewState {
413443 . demangled_name
414444 . clone ( )
415445 . unwrap_or_else ( || source_symbol_name. clone ( ) ) ;
416- self . similar_functions =
417- Some ( SimilarFunctionsState { source_symbol_name : display_name, matches : None } ) ;
446+ self . similar_functions = Some ( SimilarFunctionsState {
447+ source_symbol_name : display_name,
448+ matches : None ,
449+ search : String :: new ( ) ,
450+ search_regex : None ,
451+ show_target : true ,
452+ show_base : true ,
453+ } ) ;
418454 let Ok ( state_guard) = state. read ( ) else { return } ;
419455 start_find_similar_job ( ctx, jobs, & state_guard, source_symbol_name, column) ;
420456 }
@@ -914,6 +950,27 @@ pub fn similar_functions_col_ui(
914950 ui. label ( "No similar functions found." ) ;
915951 }
916952 Some ( matches) => {
953+ let filtered: Vec < & SimilarFunctionMatch > = matches
954+ . iter ( )
955+ . filter ( |m| {
956+ let is_base = m. object_name . ends_with ( " (base)" ) ;
957+ let is_target = m. object_name . ends_with ( " (target)" ) ;
958+ if is_target && !state. show_target {
959+ return false ;
960+ }
961+ if is_base && !state. show_base {
962+ return false ;
963+ }
964+ if let Some ( re) = & state. search_regex {
965+ let name = m. demangled_name . as_deref ( ) . unwrap_or ( & m. symbol_name ) ;
966+ if !re. is_match ( name) && !re. is_match ( & m. object_name ) {
967+ return false ;
968+ }
969+ }
970+ true
971+ } )
972+ . collect ( ) ;
973+
917974 let row_height = appearance. code_font . size ;
918975 let available_height = ui. available_height ( ) ;
919976 TableBuilder :: new ( ui)
@@ -924,10 +981,9 @@ pub fn similar_functions_col_ui(
924981 . column ( Column :: remainder ( ) . at_least ( 500.0 ) . clip ( true ) )
925982 . column ( Column :: initial ( 260.0 ) . at_least ( 260.0 ) . clip ( true ) )
926983 . body ( |body| {
927- body. rows ( row_height, matches . len ( ) , |mut row| {
928- let m = & matches [ row. index ( ) ] ;
984+ body. rows ( row_height, filtered . len ( ) , |mut row| {
985+ let m = filtered [ row. index ( ) ] ;
929986 let name = m. demangled_name . as_deref ( ) . unwrap_or ( & m. symbol_name ) ;
930- // Derive "filename (side)" for display, keep full name for tooltip.
931987 let ( base_name, suffix) =
932988 if let Some ( n) = m. object_name . strip_suffix ( " (target)" ) {
933989 ( n, " (target)" )
@@ -950,8 +1006,13 @@ pub fn similar_functions_col_ui(
9501006 ui. label ( name) ;
9511007 } ) ;
9521008 row. col ( |ui| {
953- ui. weak ( format ! ( "{file_name}{suffix}" ) )
954- . on_hover_text ( & m. object_name ) ;
1009+ ui. with_layout (
1010+ egui:: Layout :: right_to_left ( egui:: Align :: Center ) ,
1011+ |ui| {
1012+ ui. weak ( format ! ( "{file_name}{suffix}" ) )
1013+ . on_hover_text ( & m. object_name ) ;
1014+ } ,
1015+ ) ;
9551016 } ) ;
9561017 } ) ;
9571018 } ) ;
0 commit comments