Bug 365549 - [Help][Search] Changing the search results order via
org.eclipse.help.searchProcessor can cause duplicated search categories

Problem:
If "Show results categories" is enabled the search results which are
first sorted by scoring are then resorted primarily by the categories
and secondarily by the scoring (line 439: via SearchResultComparator).
Based on this order the categories are shown: a category heading line is
inserted above every result, which belongs to a different category than
the category of the previous result. The order of search results can be
changed via the "org.eclipse.help.base.searchProcessor" extension point.
These search processors are applied after (re)sorting the search results
(line 183: "ISearchResult tmp[] =
processors[p].postSearch(searchWord,results)"). A search processor is
not aware of whether "Show results categories" is enabled or disabled,
and after applying the search processors the search results may not be
primarily sorted by categories: the heading of the same categories may
be inserted more than once.

Fix:
To avoid showing the same categories multiple times a sorting by
categories only (keeping the order of results within each category)
should be done if "Show results categories" is enabled after, rather
than before applying the search processors. Because "Arrays.sort()"
guarantees to be stable (equal elements will not be reordered as a
result of the sort) the resorting by category can be simplified (without
secondarily sorting by scoring).

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=365549
Signed-off-by: Holger Voormann <eclipse@voormann.de>
1 file changed