mirror of https://github.com/encounter/objdiff.git
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.
This commit is contained in:
parent
d5dcc4f00f
commit
99641d2637
|
@ -519,7 +519,7 @@ fn asm_table_ui(
|
|||
}
|
||||
DiffViewAction::SetSymbolHighlight(left, right, scroll) => {
|
||||
symbol_state.highlighted_symbol = (left, right);
|
||||
symbol_state.scroll_highlighted_symbol_into_view = scroll;
|
||||
symbol_state.scroll_to_highlighted_symbols = (scroll, scroll);
|
||||
}
|
||||
_ => {
|
||||
ret = Some(action);
|
||||
|
@ -581,7 +581,7 @@ fn asm_table_ui(
|
|||
}
|
||||
DiffViewAction::SetSymbolHighlight(left, right, scroll) => {
|
||||
symbol_state.highlighted_symbol = (left, right);
|
||||
symbol_state.scroll_highlighted_symbol_into_view = scroll;
|
||||
symbol_state.scroll_to_highlighted_symbols = (scroll, scroll);
|
||||
}
|
||||
_ => {
|
||||
ret = Some(action);
|
||||
|
|
|
@ -136,7 +136,7 @@ pub struct DiffViewState {
|
|||
#[derive(Default)]
|
||||
pub struct SymbolViewState {
|
||||
pub highlighted_symbol: (Option<SymbolRef>, Option<SymbolRef>),
|
||||
pub scroll_highlighted_symbol_into_view: bool,
|
||||
pub scroll_to_highlighted_symbols: (bool, bool),
|
||||
pub left_symbol: Option<SymbolRefByName>,
|
||||
pub right_symbol: Option<SymbolRefByName>,
|
||||
pub reverse_fn_order: bool,
|
||||
|
@ -250,7 +250,7 @@ impl DiffViewState {
|
|||
}
|
||||
DiffViewAction::SetSymbolHighlight(left, right, scroll) => {
|
||||
self.symbol_state.highlighted_symbol = (left, right);
|
||||
self.symbol_state.scroll_highlighted_symbol_into_view = scroll;
|
||||
self.symbol_state.scroll_to_highlighted_symbols = (scroll, scroll);
|
||||
}
|
||||
DiffViewAction::SetSearch(search) => {
|
||||
self.search_regex = if search.is_empty() {
|
||||
|
@ -536,13 +536,18 @@ fn symbol_ui(
|
|||
ret = Some(DiffViewAction::Navigate(result));
|
||||
}
|
||||
});
|
||||
if selected && state.scroll_highlighted_symbol_into_view {
|
||||
let should_scroll = if column == 0 {
|
||||
&mut state.scroll_to_highlighted_symbols.0
|
||||
} else {
|
||||
&mut state.scroll_to_highlighted_symbols.1
|
||||
};
|
||||
if selected && *should_scroll {
|
||||
// Scroll the view to encompass the selected symbol in case the user selected an offscreen
|
||||
// symbol by using a keyboard shortcut.
|
||||
ui.scroll_to_rect_animation(response.rect, None, ScrollAnimation::none());
|
||||
// Then reset this flag so that we don't repeatedly scroll the view back when the user is
|
||||
// trying to manually scroll away.
|
||||
state.scroll_highlighted_symbol_into_view = false;
|
||||
*should_scroll = false;
|
||||
}
|
||||
if response.clicked() || (selected && hotkeys::enter_pressed(ui.ctx())) {
|
||||
if let Some(section) = section {
|
||||
|
|
Loading…
Reference in New Issue