@@ -260,9 +260,7 @@ public ObservableCollection<CodeExplorerItemViewModel> Projects
260
260
get => _projects ;
261
261
set
262
262
{
263
- ReorderChildNodes ( value ) ;
264
- _projects = new ObservableCollection < CodeExplorerItemViewModel > ( value . OrderBy ( o => o . NameWithSignature ) ) ;
265
- CanSearch = _projects . Any ( ) ;
263
+ _projects = ForceProjectsRefresh ( value ) ;
266
264
267
265
OnPropertyChanged ( ) ;
268
266
// Once a Project has been set, show the TreeView
@@ -271,6 +269,14 @@ public ObservableCollection<CodeExplorerItemViewModel> Projects
271
269
}
272
270
}
273
271
272
+ private ObservableCollection < CodeExplorerItemViewModel > ForceProjectsRefresh ( ObservableCollection < CodeExplorerItemViewModel > projects )
273
+ {
274
+ ReorderChildNodes ( projects ) ;
275
+ CanSearch = projects . Any ( ) ;
276
+
277
+ return new ObservableCollection < CodeExplorerItemViewModel > ( projects . OrderBy ( o => o . NameWithSignature ) ) ;
278
+ }
279
+
274
280
private void HandleStateChanged ( object sender , ParserStateEventArgs e )
275
281
{
276
282
if ( Projects == null )
@@ -304,6 +310,8 @@ private void HandleStateChanged(object sender, ParserStateEventArgs e)
304
310
UpdateNodes ( Projects , newProjects ) ;
305
311
306
312
Projects = new ObservableCollection < CodeExplorerItemViewModel > ( newProjects ) ;
313
+
314
+ FilterByName ( Projects , _filterText ) ;
307
315
}
308
316
309
317
private void UpdateNodes ( IEnumerable < CodeExplorerItemViewModel > oldList , IEnumerable < CodeExplorerItemViewModel > newList )
@@ -388,7 +396,7 @@ private void ParserState_ModuleStateChanged(object sender, ParseProgressEventArg
388
396
folderNode . AddChild ( newNode ) ;
389
397
390
398
// Force a refresh. OnPropertyChanged("Projects") didn't work.
391
- Projects = Projects ;
399
+ ForceProjectsRefresh ( Projects ) ;
392
400
}
393
401
catch ( Exception exception )
394
402
{
@@ -479,6 +487,21 @@ private void SwitchNodeState(CodeExplorerItemViewModel node, bool expandedState)
479
487
SwitchNodeState ( item , expandedState ) ;
480
488
}
481
489
}
490
+
491
+ private string _filterText ;
492
+ public string FilterText
493
+ {
494
+ get => _filterText ;
495
+ set
496
+ {
497
+ if ( ! _filterText ? . Equals ( value ) ?? true )
498
+ {
499
+ _filterText = value ;
500
+ OnPropertyChanged ( ) ;
501
+ FilterByName ( Projects , _filterText ) ;
502
+ }
503
+ }
504
+ }
482
505
483
506
public ObservableCollection < double > FontSizes { get ; } = new ObservableCollection < double > { 8 , 10 , 12 , 14 , 16 } ;
484
507
@@ -569,10 +592,10 @@ public void FilterByName(IEnumerable<CodeExplorerItemViewModel> nodes, string se
569
592
{
570
593
FilterByName ( item . Items , searchString ) ;
571
594
}
572
-
573
- item . IsVisible = item . Items . Any ( c => c . IsVisible ) ||
574
- item . Name . ToLowerInvariant ( ) . Contains ( searchString . ToLowerInvariant ( ) ) ||
575
- string . IsNullOrEmpty ( searchString ) ;
595
+
596
+ item . IsVisible = string . IsNullOrEmpty ( searchString ) ||
597
+ item . Items . Any ( c => c . IsVisible ) ||
598
+ item . Name . ToLowerInvariant ( ) . Contains ( searchString . ToLowerInvariant ( ) ) ;
576
599
}
577
600
}
578
601
0 commit comments