Skip to content

Commit 90bfbc2

Browse files
committed
Fix faulty selection update when bringing project explorer to top
When link-with-editor is enabled, the IPartListener in LinkEditorAction scheduled updateSelectionJob from both partActivated and partBroughtToTop. This introduces two issues: 1. Selection updates are triggered just because the part is (programmatically) brought to top, even if it is not activated, which is unintended. 2. Both events fire for the same editor activation, so under normal timing the second schedule() call merely resets the job timer and the job runs once. However, on slow machines (CI on Linux/GTK) the two events can fire more than LINK_HELPER_DELAY (120 ms) apart, causing the job to complete from the first event and then be rescheduled and run again from the second. This results in findSelection() being called twice, which is not the intended behavior as indicated by breaking the assertion assertEquals(1, findSelectionCount) in testLinkHelperEditorActivation. Fix: remove the job scheduling from partBroughtToTop. The partActivated event is the correct signal for "an editor became active", which is exactly what the link-with-editor feature needs to track. Fixes #1338
1 parent 0b9521c commit 90bfbc2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/actions/LinkEditorAction.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,12 @@ public void partActivated(IWorkbenchPart part) {
149149

150150
@Override
151151
public void partBroughtToTop(IWorkbenchPart part) {
152-
if (part instanceof IEditorPart && !ignoreEditorActivation) {
153-
updateSelectionJob.schedule(NavigatorPlugin.LINK_HELPER_DELAY);
154-
}
152+
// Do not schedule a selection update here:
153+
// 1. when the part is just brought to top (programmatically) but not activated,
154+
// no link update is expected.
155+
// 2. scheduling from both partActivated and partBroughtToTop can cause
156+
// the job to run twice when the two events fire more than
157+
// LINK_HELPER_DELAY apart (intermittent on slow machines).
155158
}
156159

157160
@Override

0 commit comments

Comments
 (0)