Skip to content

Commit

Permalink
Apply search results viewer limit to all levels of tree children.
Browse files Browse the repository at this point in the history
Currently viewer limit is applied to top level elements. Object[]
getChildren(Object parentElement) missing limit application.

see #2279
  • Loading branch information
raghucssit committed Sep 17, 2024
1 parent 8d8da43 commit d2a0053
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ OpenSearchPreferencesAction_label=Preferences...
OpenSearchPreferencesAction_tooltip=Open Search Preference Page
MatchFilterSelectionDialog_filter_description=Select the &matches to exclude from the search results:
MatchFilterSelectionDialog_description_label=Filter description:
MatchFilterSelectionDialog_limit_description=&Limit number of top level elements to:
MatchFilterSelectionDialog_limit_description=&Limit number of elements per level to:
MatchFilterSelectionDialog_label=Search Filters
MatchFilterSelectionDialog_error_invalid_limit=Element limit must be a positive number.
MatchFilterSelectionAction_label=&Filters...
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,7 @@ public class FileTreeContentProvider implements ITreeContentProvider, IFileSearc

@Override
public Object[] getElements(Object inputElement) {
Object[] children= getChildren(inputElement);
int elementLimit= getElementLimit();
if (elementLimit != -1 && elementLimit < children.length) {
Object[] limitedChildren= new Object[elementLimit];
System.arraycopy(children, 0, limitedChildren, 0, elementLimit);
return limitedChildren;
}
return children;
return getChildren(inputElement);
}

private int getElementLimit() {
Expand Down Expand Up @@ -202,6 +195,14 @@ public Object[] getChildren(Object parentElement) {
Set<Object> children= fChildrenMap.get(parentElement);
if (children == null)
return EMPTY_ARR;

int elementLimit = getElementLimit();
if (elementLimit != -1 && elementLimit < children.size()) {
Object[] limitedChildren = new Object[elementLimit];
System.arraycopy(children.toArray(), 0, limitedChildren, 0, elementLimit);
return limitedChildren;
}

return children.toArray();
}

Expand Down

0 comments on commit d2a0053

Please sign in to comment.