Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 425248 - Code style formatter does not allow to control white space in type definitions.
Summary: Code style formatter does not allow to control white space in type definitions.
Status: CLOSED DUPLICATE of bug 496249
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: Next   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-10 03:08 EST by Daniel Baum CLA
Modified: 2019-03-10 17:43 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Baum CLA 2014-01-10 03:08:21 EST
If I run the formatter on this code:

typedef enum
{
    TRACE_PROTOCOL_T_TRACE_PC             = 0x00,
    TRACE_PROTOCOL_T_RAW_STRING           = 0x01,
    TRACE_PROTOCOL_T_RAW_STRING_TS        = 0x02,
    TRACE_PROTOCOL_T_EFF_STRING           = 0x55,
    TRACE_PROTOCOL_T_EFF_ASSERT           = 0x56,
    TRACE_PROTOCOL_T_EFF_TRACE_EXT        = 0xAA,
    TRACE_PROTOCOL_T_EFF_TRACE_EXT_TS     = 0xAB
} TRACE_PROTOCOL_T;

it will yield:

typedef enum {
    TRACE_PROTOCOL_T_TRACE_PC = 0x00,
    TRACE_PROTOCOL_T_RAW_STRING = 0x01,
    TRACE_PROTOCOL_T_RAW_STRING_TS = 0x02,
    TRACE_PROTOCOL_T_EFF_STRING = 0x55,
    TRACE_PROTOCOL_T_EFF_ASSERT = 0x56,
    TRACE_PROTOCOL_T_EFF_TRACE_EXT = 0xAA,
    TRACE_PROTOCOL_T_EFF_TRACE_EXT_TS = 0xAB
} TRACE_PROTOCOL_T;

There is currently no way to stop it from removing the alignment.

I could imagine having a "preserve white space in type declarations" option in the configuration.
An alternative would be to allow detailed control over formatting options, e.g. minimum width for formatted type names.
Comment 1 Nathan Ridge CLA 2014-11-13 03:46:44 EST
IMO, elastic tab stops (http://nickgravgaard.com/elastictabstops/, bug 318356) would be a better way of getting this to work than trying to teach the formatter alignment conventions like this.
Comment 2 Marco Stornelli CLA 2019-03-10 13:29:02 EDT
This bug should be closed (or fixed in CDT 9.7) since it's now possible formatter tags to keep original format on a section of code.
Comment 3 Nathan Ridge CLA 2019-03-10 17:43:29 EDT
Agreed, the mechanism added in bug 496249 should be good enough for this use case.

*** This bug has been marked as a duplicate of bug 496249 ***