Skip to content

Commit 99641d2

Browse files
committed
Fix auto-scrolling to highlighted symbol only working for the left side
The flag is cleared after one scroll to avoid doing it continuously, but this breaks when we need to scroll to both the left and the right symbol at the same time. So now each side has its own flag to keep track of this state independently.
1 parent d5dcc4f commit 99641d2

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

objdiff-gui/src/views/function_diff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ fn asm_table_ui(
519519
}
520520
DiffViewAction::SetSymbolHighlight(left, right, scroll) => {
521521
symbol_state.highlighted_symbol = (left, right);
522-
symbol_state.scroll_highlighted_symbol_into_view = scroll;
522+
symbol_state.scroll_to_highlighted_symbols = (scroll, scroll);
523523
}
524524
_ => {
525525
ret = Some(action);
@@ -581,7 +581,7 @@ fn asm_table_ui(
581581
}
582582
DiffViewAction::SetSymbolHighlight(left, right, scroll) => {
583583
symbol_state.highlighted_symbol = (left, right);
584-
symbol_state.scroll_highlighted_symbol_into_view = scroll;
584+
symbol_state.scroll_to_highlighted_symbols = (scroll, scroll);
585585
}
586586
_ => {
587587
ret = Some(action);

objdiff-gui/src/views/symbol_diff.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub struct DiffViewState {
136136
#[derive(Default)]
137137
pub struct SymbolViewState {
138138
pub highlighted_symbol: (Option<SymbolRef>, Option<SymbolRef>),
139-
pub scroll_highlighted_symbol_into_view: bool,
139+
pub scroll_to_highlighted_symbols: (bool, bool),
140140
pub left_symbol: Option<SymbolRefByName>,
141141
pub right_symbol: Option<SymbolRefByName>,
142142
pub reverse_fn_order: bool,
@@ -250,7 +250,7 @@ impl DiffViewState {
250250
}
251251
DiffViewAction::SetSymbolHighlight(left, right, scroll) => {
252252
self.symbol_state.highlighted_symbol = (left, right);
253-
self.symbol_state.scroll_highlighted_symbol_into_view = scroll;
253+
self.symbol_state.scroll_to_highlighted_symbols = (scroll, scroll);
254254
}
255255
DiffViewAction::SetSearch(search) => {
256256
self.search_regex = if search.is_empty() {
@@ -536,13 +536,18 @@ fn symbol_ui(
536536
ret = Some(DiffViewAction::Navigate(result));
537537
}
538538
});
539-
if selected && state.scroll_highlighted_symbol_into_view {
539+
let should_scroll = if column == 0 {
540+
&mut state.scroll_to_highlighted_symbols.0
541+
} else {
542+
&mut state.scroll_to_highlighted_symbols.1
543+
};
544+
if selected && *should_scroll {
540545
// Scroll the view to encompass the selected symbol in case the user selected an offscreen
541546
// symbol by using a keyboard shortcut.
542547
ui.scroll_to_rect_animation(response.rect, None, ScrollAnimation::none());
543548
// Then reset this flag so that we don't repeatedly scroll the view back when the user is
544549
// trying to manually scroll away.
545-
state.scroll_highlighted_symbol_into_view = false;
550+
*should_scroll = false;
546551
}
547552
if response.clicked() || (selected && hotkeys::enter_pressed(ui.ctx())) {
548553
if let Some(section) = section {

0 commit comments

Comments
 (0)