Skip to content

Sort by the undecorated label of styled decorating label providers - #4517

Open
astrograph wants to merge 1 commit into
eclipse-platform:masterfrom
astrograph:issue-4516-undecorated-sort-label
Open

astrograph wants to merge 1 commit into
eclipse-platform:masterfrom
astrograph:issue-4516-undecorated-sort-label

Conversation

@astrograph

Copy link
Copy Markdown
Contributor

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

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>
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

   867 files  ±0     867 suites  ±0   54m 4s ⏱️ -13s
 8 466 tests ±0   8 226 ✅ ±0  240 💤 ±0  0 ❌ ±0 
21 270 runs  ±0  20 593 ✅ ±0  677 💤 ±0  0 ❌ ±0 

Results for commit 33e1742. ± Comparison against base commit 1715ff2.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 {
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

Successfully merging this pull request may close these issues.

ViewerComparator sorts by decorated labels of DecoratingStyledCellLabelProvider, which violates the comparator contract

2 participants