Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335704

Summary: [Forms] Copying text from a FormText copies to much in some cases.
Product: [Eclipse Project] Platform Reporter: riesem
Component: User AssistanceAssignee: Chris Goldthorpe <cgold>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: cgold, darnells, eclipse.felipe, riesem
Version: 3.6.2   
Target Milestone: 3.7 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Example code
none
Patch none

Description riesem CLA 2011-01-28 11:52:14 EST
Build Identifier: 3.6.1.v3659

In TextForms that use HTML tags for formatting the text is split up in segments of the same formatting. If a line consists of more than one segment, selecting and copying text from this line causes all segments preceding the selected text to be copied as well.

PATCH:
I think the bug is in TextSegment.computeSelection. The first if-condition in the method should be "(firstRow && bounds.x < leftOffset)" instead of "(firstRow && bounds.x + swidth > leftOffset)".

This way sstart would be set to s.length and no text would be added to the selection.

I am not set up to build Eclipse or SWT right now so I could not test the code. Could this also be nominated for inclusion in
3.6.2?  We are planning to releasing an RCP app based on 3.6.2.  Unfortunately, I am unable to wait to the release of 3.7.0.

Reproducible: Always

Steps to Reproduce:
1. Create a new Plug-in project in eclipse. Use the 'RCP Application with a view' as template.
2. Replace the code in view.java with the attached file and adjust the package
3. Run the application
4. Copy the word 'normal' form the TextForm
5. Paste it to any text editor.
6. The copied text is 'Boldnormal'
Comment 1 riesem CLA 2011-01-28 11:53:52 EST
Created attachment 187855 [details]
Example code
Comment 2 Chris Goldthorpe CLA 2011-02-02 14:45:37 EST
I agree with your suggested change to the code. It is too late to get this into 3.6.2 but I will get the fix into Eclipse 3.7 if no problems are discovered in testing.
Comment 3 Chris Goldthorpe CLA 2011-02-02 14:57:32 EST
Created attachment 188184 [details]
Patch
Comment 4 Chris Goldthorpe CLA 2011-02-02 14:58:30 EST
Patch applied to HEAD, Fixed.