Bug 283703 - Tab width settings being ignored for some code structures
Summary: Tab width settings being ignored for some code structures
Status: ASSIGNED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 6.0   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-16 09:10 EDT by J, King CLA
Modified: 2020-09-04 15:19 EDT (History)
3 users (show)

See Also:


Attachments
tab width in arrays is also wrong (4.11 KB, application/x-zip-compressed)
2017-09-28 10:56 EDT, Nathan Holder CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description J, King CLA 2009-07-16 09:10:36 EDT
Build ID: 20090619-0625

Steps To Reproduce:
1. Window | Preferences | General | Editors | Text Editors: Set "Displayed tab width" to 2, enable "Insert spaces for tabs".

2. Windows | Preferences | C/C++ | Code Style | Edit...: Set "Tab policy" to "Spaces only", "Indentation size" to 2, "Tab size" to 2.

3. Create new C project, add C source file.

4. Begin a "struct", e.g., struct foo { [enter]

5. Eclipse completes struct block, but puts cursor inside block indented 4 spaces instead of 2.

6. Also affects union, enum, class definitions.


More information:
Does not happen with function declarations, if/for/while statements, etc.
Comment 1 Anton Leherbauer CLA 2009-07-17 02:45:43 EDT
I assume you have also enabled the option to indent 'public', 'protected', 'private' within class bodys.
Otherwise I cannot reproduce the behavior you describe.
Comment 2 J, King CLA 2009-07-17 09:10:48 EDT
Indeed, this does solve the issue:

1. Windows | Preferences | C/C++ | Code Style | Edit...

2. Indentation tab, Indent group.

3. Uncheck "'public', 'protected', 'private' within class body".

Thank you for that tip. However, this Indent option certain looks like it should only apply to

class Foo
{
}

blocks. It is also affecting

[typedef] struct
{
}

enum
{
}

union
{
}

Can you reproduce that behavior? Those structures should have an option or options of their own.

Comment 3 Anton Leherbauer CLA 2009-07-20 02:17:49 EDT
(In reply to comment #2)
> Can you reproduce that behavior? Those structures should have an option or
> options of their own.

Yes, I can reproduce.  The indenter does not differentiate between class and non-class structures.  I'll leave this bug open for that reason.
Comment 4 Nathan Ridge CLA 2017-01-11 12:56:49 EST
Note that in C++, structs can have access specifiers just like classes.
Comment 5 Nathan Holder CLA 2017-09-28 10:56:22 EDT
Created attachment 270730 [details]
tab width in arrays is also wrong