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

Bug 373624

Summary: [formatter] Align fields in columns aligns comments wrong
Product: [Eclipse Project] JDT Reporter: Mark Jeronimus <mark.jeronimus>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: VERIFIED DUPLICATE QA Contact:
Severity: minor    
Priority: P3 CC: markus.kell.r, mateusz.matela
Version: 3.7.2   
Target Milestone: 4.8 M6   
Hardware: All   
OS: All   
Whiteboard: To be verified for 4.8 M6

Description Mark Jeronimus CLA 2012-03-08 04:28:21 EST
Build Identifier: M20120208-0800

When "Align fields in columns" (on the "Indentation" tab) is checked, the formatter calculates the wrong x-column to place the comments at.

The setting of using spaces or tabs is irrelevant. In both cases, the columns calculated is one place too far to the left. With spaces this causes all but the longest in the block to be off by 1. With tabs this causes about 25% of the lines to have one tab too few (with tab size 4). For example:

public short           format;               // u2
public short           langTagCount;         // u2
public LangTagRecord[] langTagRecords = null; // t4*langTagCount
public short           count;                // u2
public short           stringOffset;         // u2
public NameRecord[]    nameRecords;          // t12*count

I haven't found a workaround, and the option "Preserve white space between code and line comments" doesn't work (see the next bug I'm posting)

Reproducible: Always
Comment 1 Mateusz Matela CLA 2018-02-05 16:52:46 EST
This problem no longer occurs after the formatter redesign.

*** This bug has been marked as a duplicate of bug 303519 ***
Comment 2 Manoj N Palat CLA 2018-03-08 03:41:10 EST
Verified for Eclipse Photon (4.8) M6 with Build id: I20180306-0800