Skip to content

Commit 80806c6

Browse files
committed
Trim extra
1 parent 1ca1c04 commit 80806c6

File tree

1 file changed

+24
-32
lines changed

1 file changed

+24
-32
lines changed

objdiff-gui/src/views/diff.rs

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn get_asm_text(
111111
});
112112

113113
if result.is_ok() {
114-
asm_text.push_str(&line);
114+
asm_text.push_str(line.trim_end());
115115
asm_text.push('\n');
116116
}
117117
}
@@ -264,35 +264,30 @@ pub fn diff_view_ui(
264264
// Third row
265265
if left_ctx.has_symbol() && right_ctx.has_symbol() {
266266
ui.horizontal(|ui| {
267-
if state.current_view == View::FunctionDiff
267+
if (state.current_view == View::FunctionDiff
268268
&& ui
269269
.button("Change target")
270270
.on_hover_text_at_pointer(
271271
"Choose a different symbol to use as the target",
272272
)
273273
.clicked()
274-
|| hotkeys::consume_change_target_shortcut(ui.ctx())
274+
|| hotkeys::consume_change_target_shortcut(ui.ctx()))
275+
&& let Some(symbol_ref) = state.symbol_state.right_symbol.as_ref()
275276
{
276-
if let Some(symbol_ref) = state.symbol_state.right_symbol.as_ref() {
277-
ret = Some(DiffViewAction::SelectingLeft(symbol_ref.clone()));
278-
}
277+
ret = Some(DiffViewAction::SelectingLeft(symbol_ref.clone()));
279278
}
280279

281280
// Copy target ASM button.
282-
if state.current_view == View::FunctionDiff {
283-
if let Some((_, symbol_diff, symbol_idx)) = left_ctx.symbol {
284-
if let Some((obj, _)) = left_ctx.obj {
285-
if ui
286-
.button("Copy ASM")
287-
.on_hover_text_at_pointer("Copy assembly to clipboard")
288-
.clicked()
289-
{
290-
let asm_text =
291-
get_asm_text(obj, symbol_diff, symbol_idx, diff_config);
292-
ui.ctx().copy_text(asm_text);
293-
}
294-
}
295-
}
281+
if state.current_view == View::FunctionDiff
282+
&& let Some((_, symbol_diff, symbol_idx)) = left_ctx.symbol
283+
&& let Some((obj, _)) = left_ctx.obj
284+
&& ui
285+
.button("Copy ASM")
286+
.on_hover_text_at_pointer("Copy assembly to clipboard")
287+
.clicked()
288+
{
289+
let asm_text = get_asm_text(obj, symbol_diff, symbol_idx, diff_config);
290+
ui.ctx().copy_text(asm_text);
296291
}
297292
});
298293
} else if left_ctx.status.success && !left_ctx.has_symbol() {
@@ -453,18 +448,15 @@ pub fn diff_view_ui(
453448
}
454449

455450
// Copy base ASM button.
456-
if let Some((_, symbol_diff, symbol_idx)) = right_ctx.symbol {
457-
if let Some((obj, _)) = right_ctx.obj {
458-
if ui
459-
.button("Copy ASM")
460-
.on_hover_text_at_pointer("Copy assembly to clipboard")
461-
.clicked()
462-
{
463-
let asm_text =
464-
get_asm_text(obj, symbol_diff, symbol_idx, diff_config);
465-
ui.ctx().copy_text(asm_text);
466-
}
467-
}
451+
if let Some((_, symbol_diff, symbol_idx)) = right_ctx.symbol
452+
&& let Some((obj, _)) = right_ctx.obj
453+
&& ui
454+
.button("Copy ASM")
455+
.on_hover_text_at_pointer("Copy assembly to clipboard")
456+
.clicked()
457+
{
458+
let asm_text = get_asm_text(obj, symbol_diff, symbol_idx, diff_config);
459+
ui.ctx().copy_text(asm_text);
468460
}
469461
}
470462
} else if right_ctx.status.success && !right_ctx.has_symbol() {

0 commit comments

Comments
 (0)