Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351932 - formatter.indent_access_specifier_extra_spaces!=0 breaks indenter
Summary: formatter.indent_access_specifier_extra_spaces!=0 breaks indenter
Status: RESOLVED WORKSFORME
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-13 05:34 EDT by Achim Bursian CLA
Modified: 2016-12-29 01:11 EST (History)
4 users (show)

See Also:


Attachments
Exported style settings (17.08 KB, application/xml)
2011-07-13 05:36 EDT, Achim Bursian CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.