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

Bug 351932

Summary: formatter.indent_access_specifier_extra_spaces!=0 breaks indenter
Product: [Tools] CDT Reporter: Achim Bursian <abu.aud>
Component: cdt-editorAssignee: Project Inbox <cdt-editor-inbox>
Status: RESOLVED WORKSFORME QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, eclipse.sprigogin, yevshif, zeratul976
Version: 8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Exported style settings none

Description Achim Bursian CLA 2011-07-13 05:34:56 EDT
Build Identifier: I20110613-1736

In our legacy code, an indentation of 4 spaces is used, but only 2 spaces for the access specifiers (public:, protected:...) That was not supported in the CDT formatter up to now, but I was happy to find the new setting formatter.indent_access_specifier_extra_spaces in Indigo, which provides exactly what I need. I set org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces to 2, and org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header to false. These settings work fine with the CDT formatter, but if you select a code area that includes one of the access specifiers and use the indenter (Ctrl-I), the code gets indented wrongly:

Using this as base:
class OutDp: public OutDriver
{
  public:
    OutDp();
    ~OutDp();
    void reInit(int axisNr, int outputNr);
    void checkInit(int axisNr);
};

after indenting:
class OutDp: public OutDriver
{
  public:
      OutDp();
        ~OutDp();
          void reInit(int axisNr, int outputNr);
            void checkInit(int axisNr);
  };

Every line adds 2 more spaces. If the line with the "public:" specifier is not included in the selected area, the indenter works fine!

Reproducible: Always

Steps to Reproduce:
1. copy test code (see above) into a *.h file
2. select the whole class
3. press Ctrl-I
Comment 1 Achim Bursian CLA 2011-07-13 05:36:08 EDT
Created attachment 199553 [details]
Exported style settings
Comment 2 Nathan Ridge CLA 2015-12-15 21:47:39 EST
Do you still experience this problem? I imported the attached file and indented the code example you provided, and could not trigger the problem.
Comment 3 Nathan Ridge CLA 2016-12-29 01:11:25 EST
Closing per comment 2. Feel free to reopen if you're still seeing this.