Community
Participate
Working Groups
Created attachment 104124 [details] Project with "Sample Action" Build ID: I20080523-0100 Steps To Reproduce: 1. See attached project, in constributes "Sample Action"; 2. Open some Java compilation unit in editor; 3. Click "Sample Action", it will set new content, then update it and execute "undo" action. 4. During "undo" installed IBufferChangedListener will change selection in CompilationUnitEditor. I seems that this confuses underlaying StyledText. More information: java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:3759) at org.eclipse.swt.SWT.error(SWT.java:3693) at org.eclipse.swt.SWT.error(SWT.java:3664) at org.eclipse.jface.text.DefaultDocumentAdapter.getLineAtOffset(DefaultDocumentAdapter.java:201) at org.eclipse.swt.custom.StyledText.getPointAtOffset(StyledText.java:4774) at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:6765) at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:8305) at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:5416) at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:4843) at org.eclipse.jface.text.DefaultDocumentAdapter.fireTextChanged(DefaultDocumentAdapter.java:347) at org.eclipse.jface.text.DefaultDocumentAdapter.documentChanged(DefaultDocumentAdapter.java:291) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2(AbstractDocument.java:735) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:712) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:697) at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:762) at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1157) at org.eclipse.core.internal.filebuffers.SynchronizableDocument.replace(SynchronizableDocument.java:151) at org.eclipse.text.undo.DocumentUndoManager$UndoableTextChange.undoTextChange(DocumentUndoManager.java:144) at org.eclipse.text.undo.DocumentUndoManager$UndoableTextChange.undo(DocumentUndoManager.java:264) at org.eclipse.core.commands.operations.DefaultOperationHistory.doUndo(DefaultOperationHistory.java:415) at org.eclipse.core.commands.operations.DefaultOperationHistory.undo(DefaultOperationHistory.java:1268) at org.eclipse.ui.operations.UndoActionHandler.runCommand(UndoActionHandler.java:78) at org.eclipse.ui.operations.OperationHistoryActionHandler$4.run(OperationHistoryActionHandler.java:301) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:446) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:354) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507) at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog.access$6(TimeTriggeredProgressMonitorDialog.java:1) at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog$2.run(TimeTriggeredProgressMonitorDialog.java:203) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog.run(TimeTriggeredProgressMonitorDialog.java:216) at org.eclipse.ui.operations.OperationHistoryActionHandler.run(OperationHistoryActionHandler.java:316) at bugproject.actions.SampleAction.run(SampleAction.java:77) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3801) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3400) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2387) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2351) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2203) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:112) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:379) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
can you try that with Eclipse 3.4 RC4 ? I think this is a duplicate of Bug 227914
RC4? I don't see it. Only RC3 here http://download.eclipse.org/eclipse/downloads/ Latest integration build has failed tests, so probably not good to try.
(In reply to comment #2) > RC4? sorry, they still didn't declare RC4 try Build id: I20080606-0100
RC4, still exception. java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:3761) at org.eclipse.swt.SWT.error(SWT.java:3695) at org.eclipse.swt.SWT.error(SWT.java:3666) at org.eclipse.jface.text.DefaultDocumentAdapter.getLineAtOffset(DefaultDocumentAdapter.java:201) at org.eclipse.swt.custom.StyledText.getPointAtOffset(StyledText.java:4784) at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:6790) at org.eclipse.swt.custom.StyledText.updateSelection(StyledText.java:8328) at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:5425) at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:4853) at org.eclipse.jface.text.DefaultDocumentAdapter.fireTextChanged(DefaultDocumentAdapter.java:347) at org.eclipse.jface.text.DefaultDocumentAdapter.documentChanged(DefaultDocumentAdapter.java:291) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2(AbstractDocument.java:735) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:712) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:697) at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:762) at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1157) at org.eclipse.core.internal.filebuffers.SynchronizableDocument.replace(SynchronizableDocument.java:151) at org.eclipse.text.undo.DocumentUndoManager$UndoableTextChange.undoTextChange(DocumentUndoManager.java:144) at org.eclipse.text.undo.DocumentUndoManager$UndoableTextChange.undo(DocumentUndoManager.java:264) at org.eclipse.core.commands.operations.DefaultOperationHistory.doUndo(DefaultOperationHistory.java:415) at org.eclipse.core.commands.operations.DefaultOperationHistory.undo(DefaultOperationHistory.java:1268) at org.eclipse.ui.operations.UndoActionHandler.runCommand(UndoActionHandler.java:78) at org.eclipse.ui.operations.OperationHistoryActionHandler$4.run(OperationHistoryActionHandler.java:301) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:446) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:354) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507) at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog.access$6(TimeTriggeredProgressMonitorDialog.java:1) at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog$2.run(TimeTriggeredProgressMonitorDialog.java:203) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog.run(TimeTriggeredProgressMonitorDialog.java:216) at org.eclipse.ui.operations.OperationHistoryActionHandler.run(OperationHistoryActionHandler.java:316) at bugproject.actions.SampleAction.run(SampleAction.java:77) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Felipe, can you make it happen using the "Sample Action" attachment?
This problem is confusing. It has a timming in it that I don't understand yet (sometime, when I debug, the problem doesn't happen). Here is my finds: The problem is order that AbstractDocument#replace(int, int, String, long) changes the buffer and send the events. The example has a IBufferChangedListener#bufferChanged that when it runs it sets the selection range to 1460,0 Here is the order: 1) TextChanging comes in (fired by fireDocumentAboutToBeChanged()) charcount=1396, newcharcount=593, replacedcharcount=323, selection.x=1348 2) AbstractDocument changes the buffer charcount=1666 (old charcount + newcharcount - replacedcharcount) 3) IBufferChangedListener#bufferChanged (fired by fireDocumentChanged(e)) it sets selection.x=1460 StyledText accepts it cause 0<=1460<=1666 4) TextChanged runs last (also fired by fireDocumentChanged(e)). At this point StyledText updates the selection: selection.x = 1730 (old selection.x + newcharcount - replacedcharcount) 1730 is an illegal arguement (>1666) I can't fix this problem at my end. IBufferChangedListener#bufferChanged has to run after TextChanged runs. having this listener running between TextChanging and TextChanged is sort of dangerous anyway.
*** This bug has been marked as a duplicate of bug 99200 ***