Skip to content

Commit 2d09026

Browse files
raghucssitiloveeclipse
authored andcommitted
Apply search results viewer limit to all levels of tree children.
Currently viewer limit is applied to top level elements. Object[] getChildren(Object parentElement) missing limit application. see #2279
1 parent c7da703 commit 2d09026

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

bundles/org.eclipse.search/newsearch/org/eclipse/search2/internal/ui/SearchMessages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ OpenSearchPreferencesAction_label=Preferences...
8484
OpenSearchPreferencesAction_tooltip=Open Search Preference Page
8585
MatchFilterSelectionDialog_filter_description=Select the &matches to exclude from the search results:
8686
MatchFilterSelectionDialog_description_label=Filter description:
87-
MatchFilterSelectionDialog_limit_description=&Limit number of top level elements to:
87+
MatchFilterSelectionDialog_limit_description=&Limit number of elements per level to:
8888
MatchFilterSelectionDialog_label=Search Filters
8989
MatchFilterSelectionDialog_error_invalid_limit=Element limit must be a positive number.
9090
MatchFilterSelectionAction_label=&Filters...

bundles/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,7 @@ public class FileTreeContentProvider implements ITreeContentProvider, IFileSearc
5656

5757
@Override
5858
public Object[] getElements(Object inputElement) {
59-
Object[] children= getChildren(inputElement);
60-
int elementLimit= getElementLimit();
61-
if (elementLimit != -1 && elementLimit < children.length) {
62-
Object[] limitedChildren= new Object[elementLimit];
63-
System.arraycopy(children, 0, limitedChildren, 0, elementLimit);
64-
return limitedChildren;
65-
}
66-
return children;
59+
return getChildren(inputElement);
6760
}
6861

6962
private int getElementLimit() {
@@ -202,6 +195,14 @@ public Object[] getChildren(Object parentElement) {
202195
Set<Object> children= fChildrenMap.get(parentElement);
203196
if (children == null)
204197
return EMPTY_ARR;
198+
199+
int elementLimit = getElementLimit();
200+
if (elementLimit != -1 && elementLimit < children.size()) {
201+
Object[] limitedChildren = new Object[elementLimit];
202+
System.arraycopy(children.toArray(), 0, limitedChildren, 0, elementLimit);
203+
return limitedChildren;
204+
}
205+
205206
return children.toArray();
206207
}
207208

0 commit comments

Comments
 (0)