Skip to content

Commit 5d8fee8

Browse files
committed
Apply filter after reparse is requested.
1 parent 2e5f26c commit 5d8fee8

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ private void HandleStateChanged(object sender, ParserStateEventArgs e)
331331
UpdateNodes(Projects, newProjects);
332332

333333
Projects = new ObservableCollection<CodeExplorerItemViewModel>(newProjects);
334+
335+
FilterByName(Projects, _filterText);
334336
}
335337

336338
private void UpdateNodes(IEnumerable<CodeExplorerItemViewModel> oldList, IEnumerable<CodeExplorerItemViewModel> newList)
@@ -416,6 +418,8 @@ private void ParserState_ModuleStateChanged(object sender, ParseProgressEventArg
416418

417419
// Force a refresh. OnPropertyChanged("Projects") didn't work.
418420
Projects = Projects;
421+
422+
419423
}
420424
catch (Exception exception)
421425
{
@@ -507,8 +511,23 @@ private void SwitchNodeState(CodeExplorerItemViewModel node, bool expandedState)
507511
}
508512
}
509513

510-
public CommandBase RefreshCommand { get; }
514+
private string _filterText;
515+
public string FilterText
516+
{
517+
get => _filterText;
518+
set
519+
{
520+
if (!_filterText?.Equals(value) ?? true)
521+
{
522+
_filterText = value;
523+
OnPropertyChanged();
524+
FilterByName(Projects, _filterText);
525+
}
526+
}
527+
}
511528

529+
public CommandBase RefreshCommand { get; }
530+
512531
public CommandBase OpenCommand { get; }
513532

514533
public CommandBase AddTestModuleCommand { get; }

Rubberduck.Core/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@
498498
IsEnabled="{Binding CanSearch}"
499499
MinHeight="20"
500500
PreviewKeyDown="SearchBox_OnPreviewKeyDown"
501-
TextChanged="SearchBox_OnTextChanged" />
502-
501+
Text="{Binding FilterText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
502+
503503
<Image Source="{StaticResource SearchImage}"
504504
HorizontalAlignment="Right" VerticalAlignment="Center"
505505
MaxHeight="16" Margin="0,0,1,0"

Rubberduck.Core/UI/CodeExplorer/CodeExplorerControl.xaml.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public CodeExplorerControl()
1616
}
1717

1818
private CodeExplorerViewModel ViewModel => DataContext as CodeExplorerViewModel;
19-
19+
2020
private void TreeView_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
2121
{
2222
if (ViewModel != null && ViewModel.OpenCommand.CanExecute(ViewModel.SelectedItem))
@@ -32,11 +32,6 @@ private void TreeView_OnMouseRightButtonDown(object sender, MouseButtonEventArgs
3232
e.Handled = true;
3333
}
3434

35-
private void SearchBox_OnTextChanged(object sender, TextChangedEventArgs e)
36-
{
37-
ViewModel.FilterByName(ViewModel.Projects, ((TextBox)sender).Text);
38-
}
39-
4035
private void SearchIcon_OnMouseDown(object sender, MouseButtonEventArgs e)
4136
{
4237
SearchBox.Focus();

0 commit comments

Comments
 (0)