Community
Participate
Working Groups
Steps to Reproduce: 1. Create a simple html file 1: <html> 2: <head> 3: </head> 4: <body> 5: <p>Text</p> ... repeat above line 100 times 105: </body> 106: </html> 2. Go to line 105 3. Press and hold Shift+UpArrow The outline scrolls hard and hard(moving up and down). The cursor runs without block-seletion(region highlighted), and then selecting lines takes a few seconds per line. Turning off Link-with-Editor is the only workaround for now. This problem occurs on Eclipse SDK 4.2.1.M20120914-1800 Eclipse Web Developer Tools 3.4.1.v201208170345-7O7MFsPEMkBJz0wtb-ccsarPSceUIHO9iKk6XVPV Not occurs on Eclipse SDK 3.8.1.M20120914-1540 Eclipse Web Developer Tools 3.4.1.v201208170345-7O7MFsPEMkBJz0wtb-ccsarPSceUIHO9iKk6XVPV Each WTP3.4.1 is installed from juno repository and they are same on 4.2.1 and 3.8.1 of course.(I confirmed it with fc/b command also)
As far as I can inspect, org.eclipse.wst.sse.ui.internal.contentoutline.ConfigurableContentOutlinePage.PostSelectionServiceListener.selectionChanged(IWorkbenchPart, ISelection) is called per a line while key-repeating.(I confirmed 'per a line' by inserting sysout selection arg) It causes updating outline every time. On 3.8.1, it is called once at the end of key-repeating. Outline is updated once at the end. Stacktrace on 4.2.1: Suspended at first press-and-hold keys.(maybe before starting key-repeating) Thread [main] (Suspended (breakpoint at line 162 in ConfigurableContentOutlinePage$PostSelectionServiceListener)) owns: SelectionAggregator$4 (id=200) ConfigurableContentOutlinePage$PostSelectionServiceListener.selectionChanged(IWorkbenchPart, ISelection) line: 162 SelectionService.notifyListeners(String, IWorkbenchPart, ISelection) line: 140 SelectionService.access$3(SelectionService, String, IWorkbenchPart, ISelection) line: 137 SelectionService$1.selectionChanged(MPart, Object) line: 72 SelectionAggregator$2.run() line: 111 SafeRunner.run(ISafeRunnable) line: 42 SelectionAggregator.notifyListeners(MPart, Object) line: 109 SelectionAggregator.access$4(SelectionAggregator, MPart, Object) line: 106 SelectionAggregator$4$1.run() line: 163 SelectionAggregator$4(RunAndTrack).runExternalCode(Runnable) line: 53 SelectionAggregator$4.changed(IEclipseContext) line: 161 TrackableComputationExt.update(ContextChangeEvent) line: 110 EclipseContext.processScheduled(Set<Scheduled>) line: 318 EclipseContext.set(String, Object) line: 332 SelectionServiceImpl.setSelection(Object) line: 30 CompatibilityEditor(CompatibilityPart).selectionChanged(SelectionChangedEvent) line: 420 StructuredTextEditor$4.run() line: 591 SafeRunner.run(ISafeRunnable) line: 42 StructuredTextEditor$StructuredSelectionProvider.fireSelectionChanged(SelectionChangedEvent, ListenerList) line: 589 StructuredTextEditor$StructuredSelectionProvider.handleSelectionChanged(SelectionChangedEvent) line: 681 StructuredTextEditor$2.selectionChanged(SelectionChangedEvent) line: 557 Viewer$2.run() line: 164 SafeRunner.run(ISafeRunnable) line: 42 JFaceUtil$1.run(ISafeRunnable) line: 49 SafeRunnable.run(ISafeRunnable) line: 175 StructuredTextViewer(Viewer).fireSelectionChanged(SelectionChangedEvent) line: 162 StructuredTextViewer(TextViewer).fireSelectionChanged(int, int) line: 2738 StructuredTextViewer(TextViewer).selectionChanged(int, int) line: 2717 TextViewer$4.widgetSelected(SelectionEvent) line: 1836 TypedListener.handleEvent(Event) line: 248 EventTable.sendEvent(Event) line: 84 StyledText(Widget).sendEvent(Event) line: 1053 StyledText(Widget).sendEvent(int, Event, boolean) line: 1077 StyledText(Widget).sendEvent(int, Event) line: 1062 StyledText(Widget).notifyListeners(int, Event) line: 774 StyledText.sendSelectionEvent() line: 8048 StyledText.doSelection(int) line: 3219 StyledText.doLineUp(boolean) line: 2703 StyledText.doSelectionLineUp() line: 3296 StyledText.invokeAction(int) line: 6921 StyledText.handleKey(Event) line: 5911 StyledText.handleKeyDown(Event) line: 5937 StyledText$7.handleEvent(Event) line: 5629 EventTable.sendEvent(Event) line: 84 StyledText(Widget).sendEvent(Event) line: 1053 StyledText(Widget).sendEvent(int, Event, boolean) line: 1077 StyledText(Widget).sendEvent(int, Event) line: 1062 StyledText(Widget).sendKeyEvent(int, int, int, int, Event) line: 1104 StyledText(Widget).sendKeyEvent(int, int, int, int) line: 1100 StyledText(Widget).wmKeyDown(int, int, int) line: 1823 StyledText(Control).WM_KEYDOWN(int, int) line: 4892 StyledText(Control).windowProc(int, int, int, int) line: 4560 StyledText(Canvas).windowProc(int, int, int, int) line: 341 Display.windowProc(int, int, int, int) line: 4976 OS.DispatchMessageW(MSG) line: not available [native method] OS.DispatchMessage(MSG) line: 2546 Display.readAndDispatch() line: 3756 PartRenderingEngine$9.run() line: 1029 Realm.runWithDefault(Realm, Runnable) line: 332 PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 923 E4Workbench.createAndRunUI(MApplicationElement) line: 86 Workbench$5.run() line: 588 Realm.runWithDefault(Realm, Runnable) line: 332 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 543 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149 IDEApplication.start(IApplicationContext) line: 124 EclipseAppHandle.run(Object) line: 196 EclipseAppLauncher.runApplication(Object) line: 110 EclipseAppLauncher.start(Object) line: 79 EclipseStarter.run(Object) line: 353 EclipseStarter.run(String[], Runnable) line: 180 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available Method.invoke(Object, Object...) line: not available Main.invokeFramework(String[], URL[]) line: 629 Main.basicRun(String[]) line: 584 Main.run(String[]) line: 1438 Main.main(String[]) line: 1414 Stacktrace on 3.8.1: Suspended after stopping pressing keys. Thread [main] (Suspended (breakpoint at line 162 in ConfigurableContentOutlinePage$PostSelectionServiceListener)) ConfigurableContentOutlinePage$PostSelectionServiceListener.selectionChanged(IWorkbenchPart, ISelection) line: 162 WindowSelectionService(AbstractSelectionService).firePostSelection(IWorkbenchPart, ISelection) line: 179 AbstractSelectionService$2.selectionChanged(SelectionChangedEvent) line: 71 StructuredTextEditor$4.run() line: 591 SafeRunner.run(ISafeRunnable) line: 42 StructuredTextEditor$StructuredSelectionProvider.fireSelectionChanged(SelectionChangedEvent, ListenerList) line: 589 StructuredTextEditor$StructuredSelectionProvider.handlePostSelectionChanged(SelectionChangedEvent) line: 670 StructuredTextEditor$3.selectionChanged(SelectionChangedEvent) line: 563 StructuredTextViewer(TextViewer).firePostSelectionChanged(SelectionChangedEvent) line: 2755 StructuredTextViewer(TextViewer).firePostSelectionChanged(int, int) line: 2703 TextViewer$5.run() line: 2682 Display.runTimer(int) line: 4270 Display.messageProc(int, int, int, int) line: 3357 OS.DispatchMessageW(MSG) line: not available [native method] OS.DispatchMessage(MSG) line: 2546 Display.readAndDispatch() line: 3756 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2701 Workbench.runUI() line: 2665 Workbench.access$4(Workbench) line: 2499 Workbench$7.run() line: 679 Realm.runWithDefault(Realm, Runnable) line: 332 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 668 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149 IDEApplication.start(IApplicationContext) line: 124 EclipseAppHandle.run(Object) line: 196 EclipseAppLauncher.runApplication(Object) line: 110 EclipseAppLauncher.start(Object) line: 79 EclipseStarter.run(Object) line: 353 EclipseStarter.run(String[], Runnable) line: 180 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available Method.invoke(Object, Object...) line: not available Main.invokeFramework(String[], URL[]) line: 629 Main.basicRun(String[]) line: 584 Main.run(String[]) line: 1438 Main.main(String[]) line: 1414
Created attachment 222201 [details] test plug-in project
From the trace in comment 1, our selection provider, whenever it gets a plain *non* post selection notification from the source viewer ends up triggering a selection service post selection immediately. It's demonstrable with the attached view and the regular Text Editor that a *post selection* notification occurs on each change to the existing selection in the source viewer. IIRC, in 3.8 if you changed the length of the selection, selection notifications would fire immediately as well, but listeners solely listening for post selection wouldn't get notified.
I'll take a look whether this is a regression. Note that there are some actions that always (since day one) issue a selection change directly. We won't change that part.
(In reply to comment #4) > I'll take a look whether this is a regression. Note that there are some > actions that always (since day one) issue a selection change directly. We > won't change that part. Oh I have no disagreement on that, only that my post selection listener is getting more than post selection notifications.
This is pretty ugly: the concept of post-selection listeners/events is not implemented in e4 at all! See org.eclipse.ui.internal.e4.compatibility.SelectionService.addPostSelectionListener(ISelectionListener): public void addPostSelectionListener(ISelectionListener listener) { // TODO compat addPostSelectionListener addSelectionListener(listener); } In addition, the CompatibilityPart also looks like it needs work to support this. IMPORTANT NOTE: All parts that listen to post-selection events are affected by this bug. Such listeners usually use the post-selection mechanism because they do more work than is done on a normal selection change event. This is now doomed in e4 because they are notified on every selection change, e.g. when keeping the down arrow key pressed in the 'Package Explorer' they are swamped with events.
This should be fixed for 4.2.2.
This is really serious. I'll try to come up with an initial patch.
I've pushed a possible fix to the following topic branch: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/log/?h=dmegert/bug_39162 Paul and/or Eric please thoroughly review this proposed fix (I'm not yet 100% familiar with all the e4 stuff). Things to specially check: SelectionAggregator.track(MPart) - Not sure whether it is the correct place to reset OUT_POST_SELECTION with context.set(OUT_POST_SELECTION, null) here. For sure it needs to be removed form that context otherwise it remains in there. org.eclipse.e4.ui.workbench.modeling.ESelectionService - Has new methods. I assume this is OK since there's no other subclass and there is no official API for e4 yet. If not, we have to add an extension interface which will unfortunately make the code more complicated. - I was not able to the test the post-selection stuff against a pure e4 part since AFAIK there's none yet in the SDK.
To test this, a simpler way than using the attached test plug-in, is to add the following code to a view (e.g. into PackageExplorerPart.createPartControl(Composite) and make sure it is open in the target/test workspace): getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener( new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { System.out.println("received post-selection"); } } );
(In reply to comment #9) > I've pushed a possible fix to the following topic branch: > http://git.eclipse.org/c/platform/eclipse.platform.ui.git/log/?h=dmegert/ > bug_39162 Of course it's dmegert/bug_391626 i.e. http://git.eclipse.org/c/platform/eclipse.platform.ui.git/log/?h=dmegert/bug_391626
(In reply to comment #11) > > Of course it's dmegert/bug_391626 i.e. > http://git.eclipse.org/c/platform/eclipse.platform.ui.git/log/?h=dmegert/ > bug_391626 The initial cut looks reasonable, but I'm getting the post selection event before the selection event sometimes. I'm investigating. PW
(In reply to comment #12) > (In reply to comment #11) > > > > Of course it's dmegert/bug_391626 i.e. > > http://git.eclipse.org/c/platform/eclipse.platform.ui.git/log/?h=dmegert/ > > bug_391626 > > The initial cut looks reasonable, but I'm getting the post selection event > before the selection event sometimes. That would be strange but might not necessarily be a bug in the framework but the part that sends them out. If you have steps, then we should also try them on 3.8.1.
*** Bug 386640 has been marked as a duplicate of this bug. ***
I'm down to getting one extra selection event for the correct postSelection event. I'm just investigating this one last problem. PW
(In reply to comment #15) > I'm down to getting one extra selection event for the correct postSelection > event. > > I'm just investigating this one last problem. > > PW Great. The second event might not be related to the patch but be bug 387113.
I've released this to 4.2.2 and master. http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_2_maintenance&id=9db6270b7e27a2e9eaa9328d3e9a208fdea81886 http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_2_maintenance&id=b15862f11203af2f54e6371e5ede8b2b16f89367 Thanks a lot, Dani! It also looks like it might have fixed the "fire two selection event" problem as well. PW
(In reply to comment #17) > I've released this to 4.2.2 and master. > > http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/ > ?h=R4_2_maintenance&id=9db6270b7e27a2e9eaa9328d3e9a208fdea81886 > > http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/ > ?h=R4_2_maintenance&id=b15862f11203af2f54e6371e5ede8b2b16f89367 > > Thanks a lot, Dani! > > It also looks like it might have fixed the "fire two selection event" > problem as well. > > PW I just verified that the fix works and also verified that it fixes the sending of two selection events (bug 387113).
*** Bug 387113 has been marked as a duplicate of this bug. ***
File bug 393137 related to part activation where 2 post-selection events are fired.
*** Bug 397510 has been marked as a duplicate of this bug. ***