Community
Participate
Working Groups
If text in multi-line StyledText is "so" long that the scrollbar gets activated, then, the user cannot remove it anymore. To reproduce, enter "123" with a carriage return. Then, CTRL+A+CTRL-C+CTRL-V several times, until the scrollbar gets activated. Then, Select All + Cut fails... Exceptions are raised, and the stack trace is: java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:3333) at org.eclipse.swt.SWT.error(SWT.java:3272) at org.eclipse.swt.SWT.error(SWT.java:3243) at org.eclipse.swt.custom.DefaultContent.error(DefaultContent.java:670) at org.eclipse.swt.custom.DefaultContent.getLine(DefaultContent.java:478) at org.eclipse.swt.custom.StyledTextRenderer.getTextLayout(StyledTextRenderer.java:727) at org.eclipse.swt.custom.StyledTextRenderer.getTextLayout(StyledTextRenderer.java:673) at org.eclipse.swt.custom.StyledTextRenderer.calculate(StyledTextRenderer.java:200) at org.eclipse.swt.custom.StyledTextRenderer.getLineHeight(StyledTextRenderer.java:539) at org.eclipse.swt.custom.StyledText.getLineIndex(StyledText.java:3644) at org.eclipse.swt.custom.StyledText.getPartialBottomIndex(StyledText.java:3836) at org.eclipse.swt.custom.StyledText.claimBottomFreeSpace(StyledText.java:1557) at org.eclipse.swt.custom.StyledText.handleTextChanged(StyledText.java:5307) at org.eclipse.swt.custom.StyledText$6.textChanged(StyledText.java:4783) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:66) at org.eclipse.swt.custom.DefaultContent.sendTextEvent(DefaultContent.java:794) at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:787) at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:5755) at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:6466) at org.eclipse.swt.custom.StyledText.doDelete(StyledText.java:2157) at org.eclipse.swt.custom.StyledText.cut(StyledText.java:1919) at org.eclipse.swt.custom.StyledText.invokeAction(StyledText.java:5632) at com.ibm.rational.common.test.editor.framework.extensions.TextAttributeField.doPerform(Unknown Source) at com.ibm.rational.common.test.editor.framework.kernel.AbstractAttributeField$FieldAttributeInternalAction.run(Unknown Source) at com.ibm.rational.common.test.editor.framework.extensions.TextAttributeField$CutAction.run(Unknown Source) at org.eclipse.jface.action.Action.runWithEvent(Action.java:492) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:530) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:480) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:392) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:925) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3287) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2907) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1899) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1863) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:417) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:99) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:374) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:338) at org.eclipse.core.launcher.Main.basicRun(Main.java:282) at org.eclipse.core.launcher.Main.run(Main.java:977) at org.eclipse.core.launcher.Main.main(Main.java:952)
Works for me, I followed the steps in the text editor in eclipse 3.2 m6 and nothing bad happened. I was wrote this test case, maybe you modify it so it reproduces the problem: public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); StyledText text = new StyledText(shell, SWT.MULTI | SWT.V_SCROLL); text.setText("123\r"); text.setKeyBinding(SWT.MOD1 | 'a', ST.SELECT_ALL); text.invokeAction(ST.SELECT_ALL); text.invokeAction(ST.COPY); for (int i = 0; i < 50; i++) { text.invokeAction(ST.PASTE); } text.invokeAction(ST.SELECT_ALL); text.invokeAction(ST.CUT); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
It happens only when you add SWT.WRAP style flag.
Okay, I added the SWT.WRAP style flag and it still works.
I've added one, and it does not. The exception is thrown as described in the stacktrace. I have modified your own code, btw. I can show it to you if you can do netmeeting.
*** This bug has been marked as a duplicate of 128750 ***
verified with newer SWT.