Community
Participate
Working Groups
Build ID: I20090309-1800 Steps To Reproduce: 1.The copy paste works only if the selected text is of the same length in all the columns : int a; int b; int c; => works as expected But does not work for any other case : int aaaa; int bbbbbbb; int c; -> copy paste results in this : int aa int bb int c; 2. Select this method : public String foo(){ return "hi"; } Do copy paste, gives : p return "hi"; } More information:
Only happens in Java editor + folding.
*** Bug 267797 has been marked as a duplicate of this bug. ***
Will investigate.
Same issue as bug 262625: due to #253056, there is no way to tell that the user actually selected more than what the corresponding linear selection covers. The lower right corner of the selection extends over EOL, which is not surfaced by StyledText. Intstead, it returns the coordinate of the last selected character (the closing brace in case 2, 'c' in case 1).
There's hope we get bug 253056 fixed - stay tuned.
Fixed > 20090421 With 253056 fixed, TextViewer can now accurately retrieve and update StyledText's block selection, including in connect/restore in TextViewer.ViewerState. Removed the hack in SelectionProcessor that always clamped the end column of block selections. Shift left/right now works as expected (except in situations as described in bug 273117).
Thanks Tom! Raksha, please verify that your scenario is fixed.
Hi Tom, The fix seems to work for the test cases below. But found a few issues when there are empty lines in the selection : (with eclipse.buildId=I20090421-0930) (Pls let me know if these are separate issues and I need to file separate bugs for them) Testcase (a) public String foo(){ return "hi"; } 1) Select the block around String, return down 3 rows ( the third row is empty ) 2) Do cut- paste : the cut action does not cut any text, but on paste gives this : public String toString(){ return "hi";urn "hi"; } and the selection goes on to the 'public' modifier. (sometimes even replaces the wrong text) Im not sure if the block selection should allow the selection of empty spaces since the normal selection mode does not allow such selection. Testcase (b) (Add an empty line after return stmt) public String foo(){ return "hi"; } 1) Select the same block String, return and the empty line below. 2) Do cut: the selected text is cut but paste does not happen! Testcase (c) int aaaaa; int bb; 1) Select unequal length text and replace with another char (type m) --> doesnt replace the entire selection int maa; int m Testcase (d) Random selection of text along with empty spaces (extend the selection beyond the last char in a row or column) gives a "NegativeArraySizeException" for paste : java.lang.NegativeArraySizeException at org.eclipse.jface.internal.text.SelectionProcessor$2.createReplaceEdit(SelectionProcessor.java:422) at org.eclipse.jface.internal.text.SelectionProcessor$2.replace(SelectionProcessor.java:249) at org.eclipse.jface.internal.text.SelectionProcessor.replace(SelectionProcessor.java:566) at org.eclipse.jface.internal.text.SelectionProcessor.doReplace(SelectionProcessor.java:660) at org.eclipse.jface.text.TextViewer$9.run(TextViewer.java:3956) at org.eclipse.jface.text.TextViewer.wrapCompoundChange(TextViewer.java:3988) at org.eclipse.jface.text.TextViewer.paste(TextViewer.java:3919) at org.eclipse.jface.text.TextViewer.doOperation(TextViewer.java:3867) at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:921) at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1533) at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:186) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:193) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.doPasteWithImportsOperation(ClipboardOperationAction.java:501) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.internalDoOperation(ClipboardOperationAction.java:287) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction$1.run(ClipboardOperationAction.java:258) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.run(ClipboardOperationAction.java:256) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:470) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:824) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:880) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:569) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:510) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:125) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1191) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1360) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4051) at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:346) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3944) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4589) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2403) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3471) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2401) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2365) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2217) 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:1287) at org.eclipse.equinox.launcher.Main.main(Main.java:1263)
Raksha, thanks for testing. However, the fix went in on 20090421, I doubt it is available in I20090421. That said, it is certainly important to test the scenarios you found not to be working. Please reopen once you found one or more problems with a more recent build! > Im not sure if the block selection should allow the selection of empty spaces > since the normal selection mode does not allow such selection. It must be possible in block selection mode to select empty areas, otherwise you would block the user from selecting exactly in the original use case of this bug report (example 2 in comment 0).
Created attachment 133081 [details] Screen shots for cut and paste scenario (a) (In reply to comment #9) > Please reopen once you found one or more problems with a more recent build! I tested with N20090422-2000. Two of the issues(b and c) are gone.. I can still reproduce 2 scenarios (a and d): (a) Except that on paste now we get : lic String foo(){ return "hi"; } (Pls See attached screen shots) (d) 'Paste' operation (as mentioned in my prev comment) gives the "NegativeArraySizeException" . Here's the latest stack trace: java.lang.NegativeArraySizeException at org.eclipse.jface.internal.text.SelectionProcessor$2.createReplaceEdit(SelectionProcessor.java:418) at org.eclipse.jface.internal.text.SelectionProcessor$2.replace(SelectionProcessor.java:247) at org.eclipse.jface.internal.text.SelectionProcessor.replace(SelectionProcessor.java:564) at org.eclipse.jface.internal.text.SelectionProcessor.doReplace(SelectionProcessor.java:658) at org.eclipse.jface.text.TextViewer$9.run(TextViewer.java:4045) at org.eclipse.jface.text.TextViewer.wrapCompoundChange(TextViewer.java:4077) at org.eclipse.jface.text.TextViewer.paste(TextViewer.java:4008) at org.eclipse.jface.text.TextViewer.doOperation(TextViewer.java:3956) at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:921) at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1533) at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:186) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:193) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.doPasteWithImportsOperation(ClipboardOperationAction.java:501) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.internalDoOperation(ClipboardOperationAction.java:287) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction$1.run(ClipboardOperationAction.java:258) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.run(ClipboardOperationAction.java:256) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:470) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:824) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:880) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:569) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:510) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:125) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1191) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1360) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4051) at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:346) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3944) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4589) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2407) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3471) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2401) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2365) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2217) 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:1287) at org.eclipse.equinox.launcher.Main.main(Main.java:1263) > > > Im not sure if the block selection should allow the selection of empty spaces > > since the normal selection mode does not allow such selection. > > It must be possible in block selection mode to select empty areas, otherwise > you would block the user from selecting exactly in the original use case of > this bug report (example 2 in comment 0). > I meant the selection of completely empty lines, not for selection of unequal lengths.
Reopening it.
Raksha, thanks for the detailed report - I will have a look at these problems shortly.
Raksha, I cannot reproduce either of your scenarios. I also think your screenshots look fine, assuming the following meaning for the images: 1. the selection before cutting 2. the text after cutting and selection before pasting 3. the text after pasting I tried the following: - have a file Foo.java with the following contents: ----------- Foo.java -------------- public String foo(){ return "hi"; } ----------------------------------- - enable block selection mode - selection as shown using brackets: pub[lic String foo(){ ] [ return "hi"; ] [ ] } - press Ctrl+X to cut - select the "pub" remaining as text on the first line - press Ctrl+V to paste > text is cut as expected and replaced as expected, resulting in the screenshots you gave. I also cannot reproduce the NegativeArraySizeException you reported. Can you try to give more reliable steps to reproduce? Thanks, Tom -- I also found bug 273721 but don't think this has to do anything with it.
(In reply to comment #13) > Raksha, I cannot reproduce either of your scenarios. I also think your > screenshots look fine, assuming the following meaning for the images: > - press Ctrl+X to cut > - select the "pub" remaining as text on the first line > - press Ctrl+V to paste > The steps are right, except in the 2nd step where the text "pub" gets selected automatically after the cut operation (not done explicitly) so when pasted back , it replaces that text instead of pasting in the original place. The expected behaviour is to give only a vertical line(cursor) after the cut text and not select any remaining text. The images show a) Select the shown text b) Press ctrl+x to cut (automatically selects the remaining text) c) paste using ctrl+v (pub is replaced with selected text) > I also cannot reproduce the NegativeArraySizeException you reported. Can you > try to give more reliable steps to reproduce? Thanks, Tom The NASE occurs whenever there are many empty spaces in the selection which is cut and paste. This is one example : [ ] [ ] [ ] pub[lic String foo(){ ] [ return "hi"; ] [ ] } [ ]
Strange, I cannot reproduce with N20090426-win32 - are you working in the Java editor or Text editor? - do you have any other editors open on the same file?
(In reply to comment #15) > - are you working in the Java editor or Text editor? Obviously in the Java editor from the screen shot given in comment 10.
(In reply to comment #15) > - are you working in the Java editor or Text editor? Im working in the java editor > - do you have any other editors open on the same file? > Nope. It happens on any .java file with random selection of spaces and text together.
Tom, I managed to get strange behavior as well with the given example. I had folding disabled. See attached pictures for my scenario.
Created attachment 133583 [details] Initial state including whitespace
Created attachment 133584 [details] Selection before pressing Ctrl+X
Created attachment 133586 [details] Oops! It exploded ;-)
ok, can reproduce with the given steps as well.
Note that with the same code but slightly different selection I got Ctrl+X working but pasting resulted in corrupt text.
Tom, we will not recontribute to M7 for this but will need a fix for RC1 which is in 2 weeks. Hope that's OK.
(In reply to comment #24) > Tom, we will not recontribute to M7 for this but will need a fix for RC1 which > is in 2 weeks. Hope that's OK. I'll try my best... there will certainly be a fix for the exception (which just stems from setting the selection after cutting), but perhaps no perfect solution for the general case of the selection covering a fractional part of a character.
fixed in SelectionProcessor.java > 20090501
+1 to fix in RC1. Tom, the fix seems to prevent the crash but I would expect that after Cut nothing is selected. This is still not the case (see attached picutre3). Any chance for an updated fix?
Created attachment 134212 [details] picture3
> Tom, the fix seems to prevent the crash but I would expect that after Cut > nothing is selected. This is still not the case (see attached picutre3). > > Any chance for an updated fix? I agree it is unfortunate to have a non-empty post-cut selection, especially because it breaks the cut-paste idempotency. Not sure how to fix this, though - the selection shown in attachment 134212 [details] is the only selection you can reliably create yourself using keyboard and mouse interaction, since at the lower margin, the wanted selection endpoint happens to fall inside a character glyph (a tab in this case). Since block selections jump to character boundaries (except for over EOL, where it jumps to "virtual spaces"), the wanted selection is not realizable with the current concept of block selections. While StyledText would support a pixel-selection that falls inside a glyph via its API, it does not support setting such a selection using the mouse and, generally, keyboard. Note that you can create the empty selection when extending an empty selection by using ARROW_DOWN - but as soon as you start using ARROW_LEFT/RIGHT on the end line, you cannot recreate that empty selection. BlockTextSelection does not currently support sub-glyph selections at all since it relies on the character offsets.
I see, but I would expect that Cut gives the same selection as hitting Backspace. This is currently not the case: Backspace gives me the expected empty selection (though not where expected).
Filed separate bug 275439 for last mentioned issue.
Verified in I20090514-2000.