eclipse.platform.ui icon indicating copy to clipboard operation
eclipse.platform.ui copied to clipboard

sortOnly CommonSorter gets thrown away by other NavigationContent TriggerPoints

Open pazi146 opened this issue 5 months ago • 0 comments

How to reproduce:

Setup:

  • navigationContent navA providing e1 with specific trigger points (e.g. providing and acting on .xml files)
  • Object e1 belonging to navA (e.g. file foo.xml)
  • Object e2 not belonging to navA and not fulfilling its trigger points/enablement (e.g. file bar.txt)
  • sortOnly commonSorter sortF with the same or higher priority than navA valid for the objects (e.g. parent is IFolder)

https://github.com/eclipse-platform/eclipse.platform.ui/blob/2cab7ac6993b02ccd5ec3ef0e48cc23aa774772a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewerSorter.java#L132-L138

Sequence:

  • sorterService.findSorter(...) will correctly return the sorter defined by sortF (implementation: org.eclipse.ui.internal.navigator.sorters.NavigatorSorterService)
  • if (!descriptor.isSortOnly()) will be entered as navA can't be sortOnly
  • descriptor.isTriggerPoint(e2) will be false
  • sortF sorter will be wrongfully discarded

Notes: 1. if (!descriptor.isSortOnly()) will always be entered (if my understanding is correct) as this code https://github.com/eclipse-platform/eclipse.platform.ui/blob/2cab7ac6993b02ccd5ec3ef0e48cc23aa774772a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewerSorter.java#L83-L84 can't ever give a sortOnly navigationContent as source (as it can't provide items per definition). These are used in the later call: https://github.com/eclipse-platform/eclipse.platform.ui/blob/2cab7ac6993b02ccd5ec3ef0e48cc23aa774772a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewerSorter.java#L108-L110

If both navigationContents involved fail isTriggerPoint() then no sorter will ever be provided (e.g. navA as above and navB only acting on .json files)

A sortOnly commonSorter with lower priority would be a good idea in case no common sorter is found (as a fallback). That could be added right before https://github.com/eclipse-platform/eclipse.platform.ui/blob/2cab7ac6993b02ccd5ec3ef0e48cc23aa774772a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonViewerSorter.java#L118-L120

pazi146 avatar Oct 02 '24 11:10 pazi146