| Summary: | [explorer] [editor] cursor jumps and selection changes if I rename a global function or variable | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [WebTools] JSDT | Reporter: | Nitin Dahyabhai <thatnitind> | ||||
| Component: | General | Assignee: | Project Inbox <jsdt.javascript-inbox> | ||||
| Status: | RESOLVED WORKSFORME | QA Contact: | Chris Jaun <cmjaun> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | cmjaun, david_williams, stephane.wantiez | ||||
| Version: | 3.2 | ||||||
| Target Milestone: | Future | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 177639 [details]
proposed patch, only changes selection on inactive JS Editor parts
Also reproducible just by changing the name of a global variable or top-level function. * Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. Changing the selection while the user is typing is never OK. * Is there a work-around? If so, why do you believe the work-around is insufficient? Disable the Link with Editor option from the Project Explorer, but it's on by default and not an obvious cause for the problem. * How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? Manually tested. * Give a brief technical overview. Who has reviewed this fix? Text changes in the name of a global in the editor triggers both an AST structure change and regular selection notification. The AST change causes a partial refresh of the project explorer's contents and the editor's selection is then applied to the viewer. The JSDT-contributed LinkHelper that's used to make sure the right editor and JS object are shown in the editor pane tries to reveal it, but the way it's written it also forces a change in selection. And that's disastrous if the editor is active and the user is typing. * What is the risk associated with this fix? Low, adds a package-visible distinct method to reveal instead of reveal&select in the JS editor when it's not the active part. Released Nitin, This fix broke the quick outline view. "After the Quick outline opens, I can type a function name, then press Enter. The function is shown in the Editor. However, the cursor isn't placed there. The annoying thing is, if you now use the keyboard, the Editor jumps back to your previous edit location. To browse the function you need to click with the mouse on it." Specifically, line 190 in EditorUtility is causing this problem. Can't reproduce in 3.5.1. I'm facing the problem today with Eclipse Juno SR1, and I'm becoming crazy with it. I've renamed the object some hours ago, and now it's regularly jumping to the object variable declaration while I'm typing code... I've restarted Eclipse several times, but the problem is still there... |
3.2 GA Paste the following into a file and make sure it's completely expanded within the Explorer: =================================================== com.example.class1.prototype.HHJH = function () {}; function class2jj() { } =================================================== Changing the name of one of these elements and then moving the cursor elsewhere, and this has to be really fast, results in the cursor moving back into the element name. Thread [main] (Suspended (breakpoint at line 2376 in org.eclipse.jface.text.TextViewer)) org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer(org.eclipse.jface.text.TextViewer).setSelectedRange(int, int) line: 2376 org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer(org.eclipse.jface.text.source.SourceViewer).setRangeIndication(int, int, boolean) line: 1089 org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer(org.eclipse.jface.text.source.projection.ProjectionViewer).setRangeIndication(int, int, boolean) line: 1342 org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor(org.eclipse.ui.texteditor.AbstractTextEditor).setHighlightRange(int, int, boolean) line: 6033 org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor(org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor).setSelection(org.eclipse.wst.jsdt.core.ISourceReference, boolean) line: 1913 org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor(org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor).setSelection(org.eclipse.wst.jsdt.core.IJavaScriptElement) line: 1992 org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility.revealInEditor(org.eclipse.ui.IEditorPart, org.eclipse.wst.jsdt.core.IJavaScriptElement) line: 190 org.eclipse.wst.jsdt.internal.ui.navigator.JavaFileLinkHelper.activateEditor(org.eclipse.ui.IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection) line: 37 org.eclipse.ui.internal.navigator.actions.LinkEditorAction$2.run() line: 78 org.eclipse.core.runtime.SafeRunner.run(org.eclipse.core.runtime.ISafeRunnable) line: 42 org.eclipse.ui.internal.navigator.actions.LinkEditorAction$1.runInUIThread(org.eclipse.core.runtime.IProgressMonitor) line: 76 org.eclipse.ui.progress.UIJob$1.run() line: 95 org.eclipse.swt.widgets.RunnableLock.run() line: 35 org.eclipse.ui.internal.UISynchronizer(org.eclipse.swt.widgets.Synchronizer).runAsyncMessages(boolean) line: 134 org.eclipse.swt.widgets.Display.runAsyncMessages(boolean) line: 4041 org.eclipse.swt.widgets.Display.readAndDispatch() line: 3660 org.eclipse.ui.internal.Workbench.runEventLoop(org.eclipse.jface.window.Window$IExceptionHandler, org.eclipse.swt.widgets.Display) line: 2629 org.eclipse.ui.internal.Workbench.runUI() line: 2593 org.eclipse.ui.internal.Workbench.access$4(org.eclipse.ui.internal.Workbench) line: 2427 org.eclipse.ui.internal.Workbench$7.run() line: 670 org.eclipse.core.databinding.observable.Realm.runWithDefault(org.eclipse.core.databinding.observable.Realm, java.lang.Runnable) line: 332 org.eclipse.ui.internal.Workbench.createAndRunWorkbench(org.eclipse.swt.widgets.Display, org.eclipse.ui.application.WorkbenchAdvisor) line: 663 org.eclipse.ui.PlatformUI.createAndRunWorkbench(org.eclipse.swt.widgets.Display, org.eclipse.ui.application.WorkbenchAdvisor) line: 149 org.eclipse.ui.internal.ide.application.IDEApplication.start(org.eclipse.equinox.app.IApplicationContext) line: 115 org.eclipse.equinox.internal.app.EclipseAppHandle.run(java.lang.Object) line: 196 org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(java.lang.Object) line: 110 org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(java.lang.Object) line: 79 org.eclipse.core.runtime.adaptor.EclipseStarter.run(java.lang.Object) line: 369 org.eclipse.core.runtime.adaptor.EclipseStarter.run(java.lang.String[], java.lang.Runnable) line: 179 sun.reflect.NativeMethodAccessorImpl.invoke0(java.lang.reflect.Method, java.lang.Object, java.lang.Object[]) line: not available [native method] sun.reflect.NativeMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 39 sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25 java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object...) line: 597 org.eclipse.equinox.launcher.Main.invokeFramework(java.lang.String[], java.net.URL[]) line: 619 org.eclipse.equinox.launcher.Main.basicRun(java.lang.String[]) line: 574 org.eclipse.equinox.launcher.Main.run(java.lang.String[]) line: 1407 org.eclipse.equinox.launcher.Main.main(java.lang.String[]) line: 1383 Thread [main] (Suspended (breakpoint at line 2376 in org.eclipse.jface.text.TextViewer)) org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer(org.eclipse.jface.text.TextViewer).setSelectedRange(int, int) line: 2376 org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor(org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor).setSelection(org.eclipse.wst.jsdt.core.ISourceReference, boolean) line: 1959 org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor(org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor).setSelection(org.eclipse.wst.jsdt.core.IJavaScriptElement) line: 1992 org.eclipse.wst.jsdt.internal.ui.javaeditor.EditorUtility.revealInEditor(org.eclipse.ui.IEditorPart, org.eclipse.wst.jsdt.core.IJavaScriptElement) line: 190 org.eclipse.wst.jsdt.internal.ui.navigator.JavaFileLinkHelper.activateEditor(org.eclipse.ui.IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection) line: 37 org.eclipse.ui.internal.navigator.actions.LinkEditorAction$2.run() line: 78 org.eclipse.core.runtime.SafeRunner.run(org.eclipse.core.runtime.ISafeRunnable) line: 42 org.eclipse.ui.internal.navigator.actions.LinkEditorAction$1.runInUIThread(org.eclipse.core.runtime.IProgressMonitor) line: 76 org.eclipse.ui.progress.UIJob$1.run() line: 95 org.eclipse.swt.widgets.RunnableLock.run() line: 35 org.eclipse.ui.internal.UISynchronizer(org.eclipse.swt.widgets.Synchronizer).runAsyncMessages(boolean) line: 134 org.eclipse.swt.widgets.Display.runAsyncMessages(boolean) line: 4041 org.eclipse.swt.widgets.Display.readAndDispatch() line: 3660 org.eclipse.ui.internal.Workbench.runEventLoop(org.eclipse.jface.window.Window$IExceptionHandler, org.eclipse.swt.widgets.Display) line: 2629 org.eclipse.ui.internal.Workbench.runUI() line: 2593 org.eclipse.ui.internal.Workbench.access$4(org.eclipse.ui.internal.Workbench) line: 2427 org.eclipse.ui.internal.Workbench$7.run() line: 670 org.eclipse.core.databinding.observable.Realm.runWithDefault(org.eclipse.core.databinding.observable.Realm, java.lang.Runnable) line: 332 org.eclipse.ui.internal.Workbench.createAndRunWorkbench(org.eclipse.swt.widgets.Display, org.eclipse.ui.application.WorkbenchAdvisor) line: 663 org.eclipse.ui.PlatformUI.createAndRunWorkbench(org.eclipse.swt.widgets.Display, org.eclipse.ui.application.WorkbenchAdvisor) line: 149 org.eclipse.ui.internal.ide.application.IDEApplication.start(org.eclipse.equinox.app.IApplicationContext) line: 115 org.eclipse.equinox.internal.app.EclipseAppHandle.run(java.lang.Object) line: 196 org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(java.lang.Object) line: 110 org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(java.lang.Object) line: 79 org.eclipse.core.runtime.adaptor.EclipseStarter.run(java.lang.Object) line: 369 org.eclipse.core.runtime.adaptor.EclipseStarter.run(java.lang.String[], java.lang.Runnable) line: 179 sun.reflect.NativeMethodAccessorImpl.invoke0(java.lang.reflect.Method, java.lang.Object, java.lang.Object[]) line: not available [native method] sun.reflect.NativeMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 39 sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25 java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object...) line: 597 org.eclipse.equinox.launcher.Main.invokeFramework(java.lang.String[], java.net.URL[]) line: 619 org.eclipse.equinox.launcher.Main.basicRun(java.lang.String[]) line: 574 org.eclipse.equinox.launcher.Main.run(java.lang.String[]) line: 1407 org.eclipse.equinox.launcher.Main.main(java.lang.String[]) line: 1383