@@ -136,7 +136,7 @@ pub struct DiffViewState {
136136#[ derive( Default ) ]
137137pub struct SymbolViewState {
138138 pub highlighted_symbol : ( Option < SymbolRef > , Option < SymbolRef > ) ,
139- pub scroll_to_highlighted_symbols : ( bool , bool ) ,
139+ pub autoscroll_to_highlighted_symbols : bool ,
140140 pub left_symbol : Option < SymbolRefByName > ,
141141 pub right_symbol : Option < SymbolRefByName > ,
142142 pub reverse_fn_order : bool ,
@@ -248,9 +248,9 @@ impl DiffViewState {
248248 self . post_build_nav = Some ( nav) ;
249249 }
250250 }
251- DiffViewAction :: SetSymbolHighlight ( left, right, scroll ) => {
251+ DiffViewAction :: SetSymbolHighlight ( left, right, autoscroll ) => {
252252 self . symbol_state . highlighted_symbol = ( left, right) ;
253- self . symbol_state . scroll_to_highlighted_symbols = ( scroll , scroll ) ;
253+ self . symbol_state . autoscroll_to_highlighted_symbols = autoscroll ;
254254 }
255255 DiffViewAction :: SetSearch ( search) => {
256256 self . search_regex = if search. is_empty ( ) {
@@ -473,7 +473,7 @@ fn symbol_ui(
473473 symbol : & ObjSymbol ,
474474 symbol_diff : & ObjSymbolDiff ,
475475 section : Option < & ObjSection > ,
476- state : & mut SymbolViewState ,
476+ state : & SymbolViewState ,
477477 appearance : & Appearance ,
478478 column : usize ,
479479) -> Option < DiffViewAction > {
@@ -536,18 +536,12 @@ fn symbol_ui(
536536 ret = Some ( DiffViewAction :: Navigate ( result) ) ;
537537 }
538538 } ) ;
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 {
545- // Scroll the view to encompass the selected symbol in case the user selected an offscreen
546- // symbol by using a keyboard shortcut.
539+ if selected && state. autoscroll_to_highlighted_symbols {
540+ // Automatically scroll the view to encompass the selected symbol in case the user selected
541+ // an offscreen symbol by using a keyboard shortcut.
547542 ui. scroll_to_rect_animation ( response. rect , None , ScrollAnimation :: none ( ) ) ;
548- // Then reset this flag so that we don't repeatedly scroll the view back when the user is
549- // trying to manually scroll away.
550- * should_scroll = false ;
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.
551545 }
552546 if response. clicked ( ) || ( selected && hotkeys:: enter_pressed ( ui. ctx ( ) ) ) {
553547 if let Some ( section) = section {
@@ -620,7 +614,7 @@ pub fn symbol_list_ui(
620614 ui : & mut Ui ,
621615 ctx : SymbolDiffContext < ' _ > ,
622616 other_ctx : Option < SymbolDiffContext < ' _ > > ,
623- state : & mut SymbolViewState ,
617+ state : & SymbolViewState ,
624618 filter : SymbolFilter < ' _ > ,
625619 appearance : & Appearance ,
626620 column : usize ,
@@ -964,7 +958,7 @@ pub fn symbol_diff_ui(
964958 . second_obj
965959 . as_ref ( )
966960 . map ( |( obj, diff) | SymbolDiffContext { obj, diff } ) ,
967- & mut state. symbol_state ,
961+ & state. symbol_state ,
968962 filter,
969963 appearance,
970964 column,
@@ -988,7 +982,7 @@ pub fn symbol_diff_ui(
988982 . first_obj
989983 . as_ref ( )
990984 . map ( |( obj, diff) | SymbolDiffContext { obj, diff } ) ,
991- & mut state. symbol_state ,
985+ & state. symbol_state ,
992986 filter,
993987 appearance,
994988 column,
0 commit comments