Community
Participate
Working Groups
StyledText.java R1.475 I can reproducibly get a StyledText instance into a state where the following method fails. It seems that the widget carries a stale selection and has not yet adjusted to a change in its content. However, the (linear) selection returned from styled text should never extend over the content range. private boolean hasMultiLineSelection(StyledText textWidget) { Point selection= textWidget.getSelection(); int startLine= textWidget.getLineAtOffset(selection.x); int endLine= textWidget.getLineAtOffset(selection.y); return startLine != endLine; } with: java.lang.IllegalArgumentException: Index out of bounds at org.eclipse.swt.SWT.error(SWT.java:3862) at org.eclipse.swt.SWT.error(SWT.java:3796) at org.eclipse.swt.SWT.error(SWT.java:3767) at org.eclipse.swt.custom.StyledText.getLineAtOffset(StyledText.java:3894) at org.eclipse.jface.text.CursorLinePainter.hasMultiLineSelection(CursorLinePainter.java:257) at org.eclipse.jface.text.CursorLinePainter.paint(CursorLinePainter.java:225) at org.eclipse.jface.text.PaintManager.paint(PaintManager.java:298) at org.eclipse.jface.text.PaintManager.access$1(PaintManager.java:296) at org.eclipse.jface.text.PaintManager$1.run(PaintManager.java:353) Steps to reproduce: - Have the following file: ---------- Foo.java -------- public String foo(){ return "hi"; } ---------------------------- - open the file in the Java editor - open the file a second time using the Text editor - enable block selection mode in the text editor and put the caret anywhere in the whitespace beyond the end of the first line - in the Java editor, select the range marked with brackets using linear selection mode pub[lic String foo(){ return "hi"; ] } - cut the selected text using Ctrl+X > Boom
Works for me with: Version: 3.5.0 Build id: I20090427-0800 If you reproduce the problem anytime can you answer these questions: 1) from textWidget.getSelection(), which is wrong ? selection.x, selection.y or both 2) is selection.x or selection.y wrong because 'offset < 0' 'offset > getCharCount()' 3) can you add prints to doBlockSelection(boolean) doSelection(int) setSelection(int, int, boolean, boolean) and find out who is setting the selection to an invalid value ? Thank you
Do you still have this problem ? Works for me with RC3 candidate.
>Works for me with RC3 candidate. Did you test on Vista?
(In reply to comment #3) > >Works for me with RC3 candidate. > Did you test on Vista? Yes, on vista. Can you make it happen, Danni ?
Not on WindowsXP and I don't have a Vista install at hand.
I will try to reproduce over the weekend.
I can still reliably reproduce given the steps in comment 0 with HEAD of 20090531 (SWT, text components) and RC3 (everything else). The catch block in CursorLinePainter::hasMultiLineSelection is hit everytime. In addition, I now get the exception below which stems from the same problem. I will try to find out more details. !ENTRY org.eclipse.ui 4 0 2009-05-31 16:52:29.168 !MESSAGE Unhandled event loop exception !STACK 0 org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.IllegalArgumentException: Index out of bounds) at org.eclipse.swt.SWT.error(SWT.java:3884) at org.eclipse.swt.SWT.error(SWT.java:3799) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3855) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493) 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:194) 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:368) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514) at org.eclipse.equinox.launcher.Main.run(Main.java:1311) at org.eclipse.equinox.launcher.Main.main(Main.java:1287) Caused by: java.lang.IllegalArgumentException: Index out of bounds at org.eclipse.swt.SWT.error(SWT.java:3865) at org.eclipse.swt.SWT.error(SWT.java:3799) at org.eclipse.swt.SWT.error(SWT.java:3770) at org.eclipse.swt.custom.StyledText.getLocationAtOffset(StyledText.java:4252) at org.eclipse.jface.text.TextViewer.computeVirtualChars(TextViewer.java:2577) at org.eclipse.jface.text.TextViewer.getSelection(TextViewer.java:2534) at org.eclipse.ui.texteditor.AbstractTextEditor.doGetSelection(AbstractTextEditor.java:2874) at org.eclipse.ui.texteditor.AbstractTextEditor$SelectionProvider.getSelection(AbstractTextEditor.java:1486) at org.eclipse.ui.texteditor.AbstractTextEditor$9.run(AbstractTextEditor.java:624) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134) ... 23 more
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.