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

Bug 298679

Summary: StyledText center and right alignment is wrong after setting its left margin
Product: [Eclipse Project] Platform Reporter: Dmytro Mising name <dvoloshchuk>
Component: SWTAssignee: Thorsten Hake <thorsten.hake>
Status: VERIFIED FIXED QA Contact: Niraj Modi <niraj.modi>
Severity: normal    
Priority: P3 CC: AndersHessellund, cocoakevin, niraj.modi, sravankumarl, thorsten.hake, zakgof
Version: 3.6Keywords: triaged
Target Milestone: 4.8 M2   
Hardware: PC   
OS: All   
See Also: https://git.eclipse.org/r/60702
https://git.eclipse.org/r/60704
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=a3ffb152c005b14af78dbeb2418309d647a196ba
Whiteboard:
Attachments:
Description Flags
Snippet to reproduce the defect
none
Proposed patch none

Description Dmytro Mising name CLA 2009-12-31 08:28:41 EST
Build Identifier: 20090619-0625

If left margin is set for a StyledText (SWT.SINGLE) with Right or Center alignment the alignment as well as left margin become wrong.

(See the attached snippet to reproduce)

Reproducible: Always

Steps to Reproduce:
Run the attached snippet and try switching alignment to Right, Center and Left.
 
Note that when you switch to Right alignment left margin is set before setting alignment but in Center one left margin is set after setting alignment
Comment 1 Dmytro Mising name CLA 2009-12-31 08:31:06 EST
Created attachment 155153 [details]
Snippet to reproduce the defect
Comment 2 Alexander Zakusylo CLA 2012-12-25 08:20:43 EST
I stepped on this bug too (in SWT 3.8.1), is there any chance to get this fixed ?
Comment 3 Alexander Zakusylo CLA 2013-01-03 02:38:05 EST
Created attachment 225161 [details]
Proposed patch

Please consider this patch
Comment 4 Eclipse Genie CLA 2015-11-18 08:24:14 EST
New Gerrit change created: https://git.eclipse.org/r/60702
Comment 5 Eclipse Genie CLA 2015-11-18 08:28:38 EST
New Gerrit change created: https://git.eclipse.org/r/60704
Comment 6 Thorsten Hake CLA 2015-11-18 08:29:26 EST
Pushed the patch to gerrit and added a test case.
Comment 7 Niraj Modi CLA 2017-07-11 07:02:34 EDT
(In reply to Dmytro Mising name from comment #1)
> Created attachment 155153 [details]
> Snippet to reproduce the defect
Problem reproducible with on Win7 as well.
Comment 8 Niraj Modi CLA 2017-07-11 07:05:45 EDT
(In reply to Thorsten Hake from comment #6)
> Pushed the patch to gerrit and added a test case.

Thanks Thorsten, for the revised patch.
With my quick testing the latest gerrit fixes this issue but gerrit validation is failing, anyways validate the patch further targeting for 4.8 M1 release.
Comment 9 Niraj Modi CLA 2017-08-09 05:34:57 EDT
(In reply to Eclipse Genie from comment #5)
> New Gerrit change created: https://git.eclipse.org/r/60704

This is an all platform issue, problem reproducible with test Snippet on both Windows and GTK. Also, verified the above patch on Windows and GTK.

Gerrit build failure are seen due to presence of JUnits in the very same patch(known issue bug 507602)

Will commit the patch shortly.
Comment 11 Niraj Modi CLA 2017-08-09 05:41:18 EDT
(In reply to Eclipse Genie from comment #10)
> Gerrit change https://git.eclipse.org/r/60704 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=a3ffb152c005b14af78dbeb2418309d647a196ba

Thanks Oleksandr/Thorsten for you contributions.
Change is in the master, resolving now.
Comment 12 Sravan Kumar Lakkimsetti CLA 2017-09-14 05:19:00 EDT
Verified on 
Eclipse SDK
Version: Photon (4.8)
Build id: I20170913-2000
OS: Linux, v.3.10.0-327.el7.x86_64, x86_64 / gtk 3.14.13, WebKit 2.4.9