@@ -112,12 +112,14 @@ export class PreferencesEditorWidget extends BaseWidget implements StatefulWidge
112112 this . handleSearchChange ( isFiltered , leavesAreVisible ) ;
113113 } else if ( e . source === PreferenceFilterChangeSource . Scope ) {
114114 this . handleScopeChange ( isFiltered ) ;
115+ this . showInTree ( currentFirstVisible ) ;
115116 } else if ( e . source === PreferenceFilterChangeSource . Schema ) {
116117 this . handleSchemaChange ( isFiltered ) ;
118+ this . showInTree ( currentFirstVisible ) ;
117119 } else {
118120 unreachable ( e . source , 'Not all PreferenceFilterChangeSource enum variants handled.' ) ;
119121 }
120- this . resetScroll ( currentFirstVisible , e . source === PreferenceFilterChangeSource . Search && ! isFiltered ) ;
122+ this . resetScroll ( currentFirstVisible , e . source === PreferenceFilterChangeSource . Search ) ;
121123 }
122124
123125 protected handleRegistryChange ( ) : void {
@@ -235,18 +237,20 @@ export class PreferencesEditorWidget extends BaseWidget implements StatefulWidge
235237 }
236238 }
237239
238- protected doResetScroll ( nodeIDToScrollTo ?: string , filterWasCleared : boolean = false ) : void {
240+ protected doResetScroll ( nodeIDToScrollTo ?: string , filterWasModified : boolean = false ) : void {
239241 requestAnimationFrame ( ( ) => {
240242 this . scrollBar ?. update ( ) ;
241- if ( ! filterWasCleared && nodeIDToScrollTo ) {
243+ if ( filterWasModified ) {
244+ this . scrollContainer . scrollTop = 0 ;
245+ } else if ( nodeIDToScrollTo ) {
242246 const { id, collection } = this . analyzeIDAndGetRendererGroup ( nodeIDToScrollTo ) ;
243247 const renderer = collection . get ( id ) ;
244248 if ( renderer ?. visible ) {
245- this . scrollContainer . scrollTo ( 0 , renderer . node . offsetHeight ) ;
249+ this . scrollContainer . scrollTo ( 0 , renderer . node . offsetTop ) ;
246250 return ;
247251 }
248252 }
249- this . scrollContainer . scrollTop = 0 ;
253+
250254 } ) ;
251255 } ;
252256
@@ -281,26 +285,30 @@ export class PreferencesEditorWidget extends BaseWidget implements StatefulWidge
281285 if ( id && id !== this . firstVisibleChildID ) {
282286 this . firstVisibleChildID = id ;
283287 if ( ! this . shouldUpdateModelSelection ) { return ; }
284- let currentNode = this . model . getNode ( id ) ;
285- let expansionAncestor ;
286- let selectionAncestor ;
287- while ( currentNode && ( ! expansionAncestor || ! selectionAncestor ) ) {
288- if ( ! selectionAncestor && SelectableTreeNode . is ( currentNode ) ) {
289- selectionAncestor = currentNode ;
290- }
291- if ( ! expansionAncestor && ExpandableTreeNode . is ( currentNode ) ) {
292- expansionAncestor = currentNode ;
293- }
294- currentNode = currentNode . parent ;
288+ this . showInTree ( id ) ;
289+ }
290+ }
291+
292+ protected showInTree ( id : string ) : void {
293+ let currentNode = this . model . getNode ( id ) ;
294+ let expansionAncestor ;
295+ let selectionAncestor ;
296+ while ( currentNode && ( ! expansionAncestor || ! selectionAncestor ) ) {
297+ if ( ! selectionAncestor && SelectableTreeNode . is ( currentNode ) ) {
298+ selectionAncestor = currentNode ;
295299 }
296- if ( selectionAncestor ) {
297- this . currentModelSelectionId = selectionAncestor . id ;
298- expansionAncestor = expansionAncestor ?? selectionAncestor ;
299- this . model . selectIfNotSelected ( selectionAncestor ) ;
300- if ( ! this . model . isFiltered && id !== this . lastUserSelection ) {
301- this . lastUserSelection = '' ;
302- this . model . collapseAllExcept ( expansionAncestor ) ;
303- }
300+ if ( ! expansionAncestor && ExpandableTreeNode . is ( currentNode ) ) {
301+ expansionAncestor = currentNode ;
302+ }
303+ currentNode = currentNode . parent ;
304+ }
305+ if ( selectionAncestor ) {
306+ this . currentModelSelectionId = selectionAncestor . id ;
307+ expansionAncestor = expansionAncestor ?? selectionAncestor ;
308+ this . model . selectIfNotSelected ( selectionAncestor ) ;
309+ if ( ! this . model . isFiltered && id !== this . lastUserSelection ) {
310+ this . lastUserSelection = '' ;
311+ this . model . collapseAllExcept ( expansionAncestor ) ;
304312 }
305313 }
306314 }
0 commit comments