Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sortOnly CommonSorter gets thrown away by other NavigationContent TriggerPoints #2353

Open
pazi146 opened this issue Oct 2, 2024 · 0 comments

Comments

@pazi146
Copy link

pazi146 commented Oct 2, 2024

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)

ViewerSorter sorter = sorterService.findSorter(descriptor, parent, e1, e2);
if (!descriptor.isSortOnly()) { // for compatibility
if (!(descriptor.isTriggerPoint(e1) && descriptor.isTriggerPoint(e2))) {
return null;
}
}
return sorter;

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

INavigatorContentDescriptor sourceOfLvalue = getSource(e1);
INavigatorContentDescriptor sourceOfRvalue = getSource(e2);

can't ever give a sortOnly navigationContent as source (as it can't provide items per definition).
These are used in the later call:
// findSorter returns the sorter specified at the source or if it has a higher priority a sortOnly sorter that is registered for the parent
ViewerSorter lSorter = findApplicableSorter(sourceOfLvalue, parent, e1, e2);
ViewerSorter rSorter = findApplicableSorter(sourceOfRvalue, parent, e1, e2);

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

if (sorter != null) {
return sorter.compare(viewer, e1, e2);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant