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

Bug 322326

Summary: Auto code insert does not honour user whitespace settings
Product: [Eclipse Project] JDT Reporter: Timothy Mowlem <tmowlem>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r, remy.suen
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Timothy Mowlem CLA 2010-08-11 05:25:02 EDT
Build Identifier: 3.7.0 Build id: I20100805-1700

I have Eclipse set to use tabs instead of spaces (my choice) in the preferences (General->Editors->Text Editors, tab width is 4 and "Insert Spaces for Tabs" is unchecked). Yet when code is automatically added by Eclipse (e.g. when an error is shown and I select a suggested fix which adds code) then the code inserted completely ignores my tabs preference and uses spaces.

Code added by Eclipse should honour the formatting and whitespace options that are in effect.

An example is when a piece of code in a try block trows an exception with no catch defined. It shows as an error. However over and a quick fix option is add catch clause. This inserts a catch clause and block but the inserted code has spaces before the inserted lines. this is REALLY ANNOYING as I have to go through and hand change them all to tabs.

Reproducible: Always

Steps to Reproduce:
1. Set prefs to use tabs not spaces
2. Perform an action that causes Eclipse to add code automatically
3. Spend all day laboriously hand changing it to what you said you wanted in the first place
4. Grow old quickly and die young as an embittered shell of a person!
Comment 1 Timothy Mowlem CLA 2010-08-11 05:25:44 EDT
Is like this in all versions prior to and including 3.7M1
Comment 2 Remy Suen CLA 2010-08-11 05:50:03 EDT
If you set your Java formatter to use spaces, this shouldn't be a problem.
Comment 3 Markus Keller CLA 2010-08-11 06:27:55 EDT
You changed the settings for plain text editors. The Java editor has many more formatting options, and those have to be configured in Java > Code Style > Formatter.
Comment 4 Timothy Mowlem CLA 2010-08-11 13:05:03 EDT
Apologies but I missed the "Use spaces to indent wrapped lines" checkbox in the formatter indentation options. Having unchecked this it seems to work okay.