@@ -6,7 +6,10 @@ use objdiff_core::{
6
6
diff:: {
7
7
DiffObjConfig , ObjectDiff , SymbolDiff ,
8
8
data:: BYTES_PER_ROW ,
9
- display:: { ContextItem , DiffText , HoverItem , HoverItemColor , SymbolFilter , SymbolNavigationKind , display_row} ,
9
+ display:: {
10
+ ContextItem , DiffText , HoverItem , HoverItemColor , SymbolFilter , SymbolNavigationKind ,
11
+ display_row,
12
+ } ,
10
13
} ,
11
14
obj:: { InstructionArgValue , Object , Symbol } ,
12
15
util:: ReallySigned ,
@@ -61,16 +64,25 @@ impl<'a> DiffColumnContext<'a> {
61
64
}
62
65
63
66
#[ inline]
64
- pub fn has_symbol ( & self ) -> bool { self . symbol . is_some ( ) }
67
+ pub fn has_symbol ( & self ) -> bool {
68
+ self . symbol . is_some ( )
69
+ }
65
70
66
71
#[ inline]
67
- pub fn id ( & self ) -> Option < & str > { self . symbol . map ( |( symbol, _, _) | symbol. name . as_str ( ) ) }
72
+ pub fn id ( & self ) -> Option < & str > {
73
+ self . symbol . map ( |( symbol, _, _) | symbol. name . as_str ( ) )
74
+ }
68
75
}
69
76
70
77
/// Obtains the assembly text for a given symbol diff, suitable for copying to clipboard.
71
- fn get_asm_text ( obj : & Object , symbol_diff : & SymbolDiff , symbol_idx : usize , diff_config : & DiffObjConfig ) -> String {
78
+ fn get_asm_text (
79
+ obj : & Object ,
80
+ symbol_diff : & SymbolDiff ,
81
+ symbol_idx : usize ,
82
+ diff_config : & DiffObjConfig ,
83
+ ) -> String {
72
84
let mut asm_text = String :: new ( ) ;
73
-
85
+
74
86
for ins_row in & symbol_diff. instruction_rows {
75
87
let mut line = String :: new ( ) ;
76
88
let result = display_row ( obj, symbol_idx, ins_row, diff_config, |segment| {
@@ -97,13 +109,13 @@ fn get_asm_text(obj: &Object, symbol_diff: &SymbolDiff, symbol_idx: usize, diff_
97
109
line. push_str ( & text) ;
98
110
Ok ( ( ) )
99
111
} ) ;
100
-
112
+
101
113
if result. is_ok ( ) {
102
114
asm_text. push_str ( & line) ;
103
115
asm_text. push ( '\n' ) ;
104
116
}
105
117
}
106
-
118
+
107
119
asm_text
108
120
}
109
121
@@ -255,15 +267,17 @@ pub fn diff_view_ui(
255
267
if state. current_view == View :: FunctionDiff
256
268
&& ui
257
269
. button ( "Change target" )
258
- . on_hover_text_at_pointer ( "Choose a different symbol to use as the target" )
270
+ . on_hover_text_at_pointer (
271
+ "Choose a different symbol to use as the target" ,
272
+ )
259
273
. clicked ( )
260
274
|| hotkeys:: consume_change_target_shortcut ( ui. ctx ( ) )
261
275
{
262
276
if let Some ( symbol_ref) = state. symbol_state . right_symbol . as_ref ( ) {
263
277
ret = Some ( DiffViewAction :: SelectingLeft ( symbol_ref. clone ( ) ) ) ;
264
278
}
265
279
}
266
-
280
+
267
281
// Copy target ASM button.
268
282
if state. current_view == View :: FunctionDiff {
269
283
if let Some ( ( _, symbol_diff, symbol_idx) ) = left_ctx. symbol {
@@ -273,7 +287,8 @@ pub fn diff_view_ui(
273
287
. on_hover_text_at_pointer ( "Copy assembly to clipboard" )
274
288
. clicked ( )
275
289
{
276
- let asm_text = get_asm_text ( obj, symbol_diff, symbol_idx, diff_config) ;
290
+ let asm_text =
291
+ get_asm_text ( obj, symbol_diff, symbol_idx, diff_config) ;
277
292
ui. ctx ( ) . copy_text ( asm_text) ;
278
293
}
279
294
}
@@ -436,7 +451,7 @@ pub fn diff_view_ui(
436
451
{
437
452
ret = Some ( DiffViewAction :: SelectingRight ( symbol_ref. clone ( ) ) ) ;
438
453
}
439
-
454
+
440
455
// Copy base ASM button.
441
456
if let Some ( ( _, symbol_diff, symbol_idx) ) = right_ctx. symbol {
442
457
if let Some ( ( obj, _) ) = right_ctx. obj {
@@ -445,7 +460,8 @@ pub fn diff_view_ui(
445
460
. on_hover_text_at_pointer ( "Copy assembly to clipboard" )
446
461
. clicked ( )
447
462
{
448
- let asm_text = get_asm_text ( obj, symbol_diff, symbol_idx, diff_config) ;
463
+ let asm_text =
464
+ get_asm_text ( obj, symbol_diff, symbol_idx, diff_config) ;
449
465
ui. ctx ( ) . copy_text ( asm_text) ;
450
466
}
451
467
}
0 commit comments