From 95528fa8d298b4c39c0314afe2a8cf6312f3ad42 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 29 Nov 2024 13:10:00 -0500 Subject: [PATCH] Found a better place to clear the autoscroll flag DiffViewState::post_update is where the flag gets set, so clearing it right before that at the start of the function seems to make the most sense, instead of doing it in App::update. --- objdiff-gui/src/app.rs | 2 -- objdiff-gui/src/views/symbol_diff.rs | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/objdiff-gui/src/app.rs b/objdiff-gui/src/app.rs index 059186b..b79d1c6 100644 --- a/objdiff-gui/src/app.rs +++ b/objdiff-gui/src/app.rs @@ -831,8 +831,6 @@ impl eframe::App for App { } else { symbol_diff_ui(ui, diff_state, appearance) }; - // Clear the autoscroll flag so it doesn't scroll continuously. - diff_state.symbol_state.autoscroll_to_highlighted_symbols = false; }); project_window(ctx, state, show_project_config, config_state, appearance); diff --git a/objdiff-gui/src/views/symbol_diff.rs b/objdiff-gui/src/views/symbol_diff.rs index 356c73f..0d008c3 100644 --- a/objdiff-gui/src/views/symbol_diff.rs +++ b/objdiff-gui/src/views/symbol_diff.rs @@ -199,6 +199,9 @@ impl DiffViewState { ctx.output_mut(|o| o.open_url = Some(OpenUrl::new_tab(result.scratch_url))); } + // Clear the autoscroll flag so that it doesn't scroll continuously. + self.symbol_state.autoscroll_to_highlighted_symbols = false; + let Some(action) = action else { return; }; @@ -540,8 +543,9 @@ fn symbol_ui( // Automatically 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()); - // This state flag will be reset in App::update at the end of every frame so that we don't - // continuously scroll the view back when the user is trying to manually scroll away. + // This autoscroll state flag will be reset in DiffViewState::post_update at the end of + // every frame so that we don't continuously scroll the view back when the user is trying to + // manually scroll away. } if response.clicked() || (selected && hotkeys::enter_pressed(ui.ctx())) { if let Some(section) = section {