Repository navigation
Sort by the undecorated label of styled decorating label providers - #4517
Open
astrograph wants to merge 1 commit into
Open
astrograph wants to merge 1 commit into
astrograph wants to merge 1 commit into
Conversation
ViewerComparator.getLabel unwraps a DecoratingLabelProvider (Bug 364735) but sorts by the decorated text of a DecoratingStyledCellLabelProvider, the label provider of every CommonViewer. Decorations are computed in a background job and may change the label while a sort runs, which violates the comparator contract and lets TimSort throw "Comparison method violates its general contract". Fixes eclipse-platform#4516 Signed-off-by: Philipp SALZGEBER <Philipp.SALZGEBER@bachmann.info>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new regression test class is missing from the explicit viewer test suite, so normal suite-based runs skip both tests.
1 open issue
What changed in this PR
This PR addresses #4516 by making JFace’s ViewerComparator use undecorated styled labels, preventing background decoration updates from destabilizing Common Navigator sorting.
Changes:
- Read labels directly from the underlying styled label provider before comparing elements.
- Add regression tests for styled and plain decorating label providers.
| File | Description |
|---|---|
| tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/viewers/ViewerComparatorDecoratedLabelTest.java | Adds tests verifying that decorations do not affect sorting. |
| bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java | Uses underlying styled text to avoid decoration-dependent ordering. |
Review effort: Balanced
| * label while a sort runs, so {@link ViewerComparator} must sort by the | ||
| * undecorated label (Bug 364735, Issue #4516). | ||
| */ | ||
| public class ViewerComparatorDecoratedLabelTest { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

ViewerComparator.getLabel unwraps a DecoratingLabelProvider (Bug 364735) but sorts by the decorated text of a
DecoratingStyledCellLabelProvider, the label provider of every CommonViewer. Decorations are computed in a background job and may change the label while a sort runs, which violates the comparator contract and lets TimSort throw "Comparison method violates its general contract".
Fixes #4516