Skip to content

Commit a984db2

Browse files
committed
CCE on selecting "Show remaining..." in JUnit view
CCE happens because we always select expandable node on click and because the JUnit related selection listener code queries the selection from the widget instead of using selection from selection event while reacting on selection change. This is unusual, but allowed. However, setting selection in first place is actually not needed, the only reason to do so was to reveal last element after expanding, so that user can simply click few times if needed. Revealing shown items however can be done without selection, so we don't run in such corner cases here. Fixes #1360
1 parent 43161a6 commit a984db2

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java

+11-12
Original file line numberDiff line numberDiff line change
@@ -1154,19 +1154,18 @@ void handleExpandableNodeClicked(Widget w) {
11541154
createTreeItem(parent, element, -1);
11551155
}
11561156

1157-
// If we've expanded but still have not reached the limit
1158-
// select new expandable node, so user can click through
1159-
// to the end
1157+
// reset the selection. client's selection listener should not be triggered.
1158+
// there was only one selection on Expandable Node.
1159+
Item[] curSel = tree.getSelection();
1160+
if (curSel.length == 1) {
1161+
tree.deselect((TreeItem) curSel[0]);
1162+
}
1163+
1164+
// Scroll to the last element, so user can see what's expanded
1165+
// end continue expanding if needed
11601166
Object lastElement = getLastElement(parent);
1161-
if (lastElement instanceof ExpandableNode node) {
1162-
setSelection(new StructuredSelection(node), true);
1163-
} else {
1164-
// reset the selection. client's selection listener should not be triggered.
1165-
// there was only one selection on Expandable Node.
1166-
Item[] curSel = tree.getSelection();
1167-
if (curSel.length == 1) {
1168-
tree.deselect((TreeItem) curSel[0]);
1169-
}
1167+
if (lastElement instanceof ExpandableNode) {
1168+
reveal(lastElement);
11701169
}
11711170
} finally {
11721171
tree.setRedraw(true);

0 commit comments

Comments
 (0)