Permalink
Browse files

add "No results found!" message to SearchPanel, if no results are found.

  • Loading branch information...
1 parent 6a0d2bc commit 4567a708c146fded1dbdfb60f34679a82c7a7a2b @siegfriedpammer siegfriedpammer committed Oct 26, 2011
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs
@@ -101,7 +101,11 @@ static void SearchPatternChangedCallback(DependencyObject d, DependencyPropertyC
void UpdateSearch()
{
- messageView.IsOpen = false;
+ // only reset as long as there are results
+ // if no results are found, the "no matches found" message should not flicker.
+ // if results are found by the next run, the message will be hidden inside DoSearch ...
+ if (renderer.CurrentResults.Any())
+ messageView.IsOpen = false;
strategy = SearchStrategyFactory.Create(SearchPattern ?? "", !MatchCase, WholeWords, UseRegex ? SearchMode.RegEx : SearchMode.Normal);
DoSearch(true);
}
@@ -217,6 +221,7 @@ void DoSearch(bool changeSelection)
{
renderer.CurrentResults.Clear();
currentResult = null;
+
if (!string.IsNullOrEmpty(SearchPattern)) {
int offset = textArea.Caret.Offset;
if (changeSelection) {
@@ -231,6 +236,12 @@ void DoSearch(bool changeSelection)
}
renderer.CurrentResults.Add(result);
}
+ if (!renderer.CurrentResults.Any()) {
+ messageView.IsOpen = true;
+ messageView.Content = "No matches found!";
+ messageView.PlacementTarget = searchTextBox;
+ } else
+ messageView.IsOpen = false;
}
textArea.TextView.InvalidateLayer(KnownLayer.Selection);
}

0 comments on commit 4567a70

Please sign in to comment.