Bug 267804 - [block selection][projection] copy paste does not work for unequal length selected text
Summary: [block selection][projection] copy paste does not work for unequal length sel...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 3.5 RC1   Edit
Assignee: Tom Hofmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 267797 (view as bug list)
Depends on: 253056
Blocks:
  Show dependency tree
 
Reported: 2009-03-10 06:01 EDT by Raksha Vasisht CLA
Modified: 2009-05-15 11:23 EDT (History)
3 users (show)

See Also:
daniel_megert: review+


Attachments
Screen shots for cut and paste scenario (a) (6.35 KB, image/png)
2009-04-24 05:06 EDT, Raksha Vasisht CLA
no flags Details
Initial state including whitespace (4.49 KB, image/png)
2009-04-28 12:28 EDT, Dani Megert CLA
no flags Details
Selection before pressing Ctrl+X (3.92 KB, image/png)
2009-04-28 12:29 EDT, Dani Megert CLA
no flags Details
Oops! It exploded ;-) (21.96 KB, image/png)
2009-04-28 12:30 EDT, Dani Megert CLA
no flags Details
picture3 (4.02 KB, image/png)
2009-05-04 05:34 EDT, Dani Megert CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raksha Vasisht CLA 2009-03-10 06:01:17 EDT
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:
Comment 1 Dani Megert CLA 2009-03-10 11:49:34 EDT
Only happens in Java editor + folding.
Comment 2 Dani Megert CLA 2009-03-10 12:51:25 EDT
*** Bug 267797 has been marked as a duplicate of this bug. ***
Comment 3 Tom Hofmann CLA 2009-03-11 03:57:15 EDT
Will investigate.
Comment 4 Tom Hofmann CLA 2009-04-15 15:01:02 EDT
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).
Comment 5 Dani Megert CLA 2009-04-16 01:58:14 EDT
There's hope we get bug 253056 fixed - stay tuned.
Comment 6 Tom Hofmann CLA 2009-04-21 15:07:31 EDT
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).
Comment 7 Dani Megert CLA 2009-04-22 05:30:51 EDT
Thanks Tom!

Raksha, please verify that your scenario is fixed.
Comment 8 Raksha Vasisht CLA 2009-04-24 03:27:39 EDT
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)



Comment 9 Tom Hofmann CLA 2009-04-24 03:37:59 EDT
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). 

Comment 10 Raksha Vasisht CLA 2009-04-24 05:06:17 EDT
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.
Comment 11 Raksha Vasisht CLA 2009-04-24 05:08:11 EDT
Reopening it.
Comment 12 Tom Hofmann CLA 2009-04-24 05:15:04 EDT
Raksha, thanks for the detailed report - I will have a look at these problems shortly.
Comment 13 Tom Hofmann CLA 2009-04-26 09:48:11 EDT
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.
Comment 14 Raksha Vasisht CLA 2009-04-27 03:30:56 EDT
(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";    ]
    [                    ]
 }  [                    ]


Comment 15 Tom Hofmann CLA 2009-04-27 05:12:59 EDT
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?
Comment 16 Tom Hofmann CLA 2009-04-27 05:15:19 EDT
(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.


Comment 17 Raksha Vasisht CLA 2009-04-27 06:01:07 EDT
(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. 
Comment 18 Dani Megert CLA 2009-04-28 12:28:11 EDT
Tom, I managed to get strange behavior as well with the given example. I had folding disabled. See attached pictures for my scenario.
Comment 19 Dani Megert CLA 2009-04-28 12:28:42 EDT
Created attachment 133583 [details]
Initial state including whitespace
Comment 20 Dani Megert CLA 2009-04-28 12:29:09 EDT
Created attachment 133584 [details]
Selection before pressing Ctrl+X
Comment 21 Dani Megert CLA 2009-04-28 12:30:19 EDT
Created attachment 133586 [details]
Oops! It exploded ;-)
Comment 22 Tom Hofmann CLA 2009-04-28 14:54:31 EDT
ok, can reproduce with the given steps as well.
Comment 23 Dani Megert CLA 2009-04-29 02:01:06 EDT
Note that with the same code but slightly different selection I got Ctrl+X working but pasting resulted in corrupt text.
Comment 24 Dani Megert CLA 2009-04-30 09:25:23 EDT
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.
Comment 25 Tom Hofmann CLA 2009-04-30 09:32:30 EDT
(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.
Comment 26 Tom Hofmann CLA 2009-05-01 12:02:27 EDT
fixed in SelectionProcessor.java > 20090501
Comment 27 Dani Megert CLA 2009-05-04 05:28:52 EDT
+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?
Comment 28 Dani Megert CLA 2009-05-04 05:34:59 EDT
Created attachment 134212 [details]
picture3
Comment 29 Tom Hofmann CLA 2009-05-04 05:57:51 EDT
> 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.


Comment 30 Dani Megert CLA 2009-05-04 06:06:00 EDT
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).
Comment 31 Dani Megert CLA 2009-05-08 06:45:24 EDT
Filed separate bug 275439 for last mentioned issue.
Comment 32 Markus Keller CLA 2009-05-15 11:23:32 EDT
Verified in I20090514-2000.