Skip to content

Commit ef27237

Browse files
committed
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.
1 parent 446dd68 commit ef27237

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

objdiff-gui/src/app.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,6 @@ impl eframe::App for App {
831831
} else {
832832
symbol_diff_ui(ui, diff_state, appearance)
833833
};
834-
// Clear the autoscroll flag so it doesn't scroll continuously.
835-
diff_state.symbol_state.autoscroll_to_highlighted_symbols = false;
836834
});
837835

838836
project_window(ctx, state, show_project_config, config_state, appearance);

objdiff-gui/src/views/symbol_diff.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ impl DiffViewState {
199199
ctx.output_mut(|o| o.open_url = Some(OpenUrl::new_tab(result.scratch_url)));
200200
}
201201

202+
// Clear the autoscroll flag so that it doesn't scroll continuously.
203+
self.symbol_state.autoscroll_to_highlighted_symbols = false;
204+
202205
let Some(action) = action else {
203206
return;
204207
};
@@ -540,8 +543,9 @@ fn symbol_ui(
540543
// Automatically scroll the view to encompass the selected symbol in case the user selected
541544
// an offscreen symbol by using a keyboard shortcut.
542545
ui.scroll_to_rect_animation(response.rect, None, ScrollAnimation::none());
543-
// This state flag will be reset in App::update at the end of every frame so that we don't
544-
// continuously scroll the view back when the user is trying to manually scroll away.
546+
// This autoscroll state flag will be reset in DiffViewState::post_update at the end of
547+
// every frame so that we don't continuously scroll the view back when the user is trying to
548+
// manually scroll away.
545549
}
546550
if response.clicked() || (selected && hotkeys::enter_pressed(ui.ctx())) {
547551
if let Some(section) = section {

0 commit comments

Comments
 (0)